Daemon loses __file__ reference after a while

ivdneut at gmail.com ivdneut at gmail.com
Tue Jul 24 14:17:51 CEST 2012

Hello all,

I have a deamon process that runs for some considerable time (weeks) without any problems. At some point it starts throwing the following exception:

  File "/some/path/scheduler.py", line 376, in applyrule
    result = execrule(rule_code)
  File "/some/path/scheduler.py", line 521, in execrule
    rulepath = os.path.dirname(__file__)+"/"+'/'.join(rule['modules'])+"/"+rule['rulename']
NameError: name '__file__' is not defined

This section is executed *all the time* but somehow stops working after a while. I have searched the web and this group, but can only find references to this occurring when run interactively, which is not the case here. When I restart the process the problem, at least temporarily, disappears.

I am running the script in a virtual-env on a stock Red Hat EL 6.2 installation:

(my-env)[user at host ~]$ python --version
Python 2.6.6
(my-env)[user at host ~]$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.2 (Santiago)

Thank you very much in advance for any pointers as to where to start looking to find the problem.


(If this post occurs twice, I apologize. Google groups was complaining about my post taking long to process and to wait a few minutes and try again if it didn't show up, which as far as I can determine, it didn't.)

More information about the Python-list mailing list