Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'executed': 0.07; 'skip:/ 10': 0.07; 'stops': 0.07; 'utf-8': 0.07; 'python': 0.09; 'exception:': 0.09; 'nameerror:': 0.09; 'cc:addr :python-list': 0.10; '--version': 0.16; '24,': 0.16; 'code?': 0.16; 'descriptors,': 0.16; 'process?': 0.16; 'skip:o 70': 0.16; 'wrote:': 0.17; 'working.': 0.17; 'creates': 0.18; 'suddenly': 0.22; 'defined': 0.22; 'runs': 0.22; 'installation': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'linux': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'skip:( 20': 0.28; 'run': 0.28; '-0700,': 0.29; 'cat': 0.29; 'code': 0.31; 'point': 0.31; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'getting': 0.33; 'traceback': 0.33; 'loss': 0.34; 'server': 0.35; 'similar': 0.35; 'but': 0.36; 'stock': 0.36; 'problems': 0.36; 'ones': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'release': 0.39; 'hello,': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'red': 0.60; 'content-disposition:inline': 0.60; 'email addr:gmail.com': 0.63; 'jul': 0.65; 'drops': 0.91; 'received:86': 0.93; 'received:hu': 0.93; 'online,': 0.98 X-Spam-Score: -2.085 X-Spam-Level: X-Spam-Status: No, score=-2.085 tagged_above=-20 required=4 tests=[AWL=0.414, BAYES_00=-2.599, RDNS_NONE=0.1] Date: Tue, 24 Jul 2012 14:24:31 +0200 From: Ervin =?utf-8?Q?Heged=C3=BCs?= To: "ivdneut@gmail.com" Subject: Re: Daemon loses __file__ reference after a while. References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343132808 news.xs4all.nl 6948 [2001:888:2000:d::a6]:52642 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25982 hello, On Tue, Jul 24, 2012 at 04:48:42AM -0700, ivdneut@gmail.com wrote: > Hello, > > I have a daemon process that runs for a considerable amount of time (weeks on end) without any problems. At some point I start getting the exception: > > Exception info: Traceback (most recent call last): > File "scheduler.py", line 376, in applyrule > result = execrule(rule_code) > File "scheduler.py", line 521, in execrule > rulepath = os.path.dirname(__file__)+"/"+'/'.join(rule['modules'])+"/"+rule['rulename'] > NameError: name '__file__' is not defined > > This section of the code is executed in this process *all the time*, but suddenly stops working. I have been searching for similar issues online, but only come accross people having problems because they run the script interactively. This is not the case here. could you send the relevant part of the code? I mean: how do you daemonize your process? > I am running python from a virtual-env installation from a stock Red Hat EL 6.2 installation: > > (virtual-env)[user@host ~]$ python --version > Python 2.6.6 > (virtual-env)[user@host ~]$ cat /etc/redhat-release > Red Hat Enterprise Linux Server release 6.2 (Santiago) If you use fork(), it drops all file descriptors, and creates new ones - may be then loss the __file__...? a. -- I � UTF-8