Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Daemon loses __file__ reference after a while

Reply
Thread Tools

Daemon loses __file__ reference after a while

 
 
ivdneut@gmail.com
Guest
Posts: n/a
 
      07-24-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@host ~]$ python --version
Python 2.6.6
(my-env)[user@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.

Ian.

(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 ifit didn't show up, which as far as I can determine, it didn't.)
 
Reply With Quote
 
 
 
 
Laszlo Nagy
Guest
Posts: n/a
 
      07-24-2012
On 2012-07-24 14:17, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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

It is not a direct solution to your problem, but can you save the value
of os.path.dirname(__file__) into another variable?

 
Reply With Quote
 
 
 
 
ivdneut@gmail.com
Guest
Posts: n/a
 
      07-24-2012
On Tuesday, July 24, 2012 2:29:19 PM UTC+2, Laszlo Nagy wrote:
> On 2012-07-24 14:17, (E-Mail Removed) wrote:
> > 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
> It is not a direct solution to your problem, but can you save the value
> of os.path.dirname(__file__) into another variable?



That might be a workaround that I'm seriously pondering as well.

Thank you.

Ian.

(sorry for google messing up my posts)
 
Reply With Quote
 
ivdneut@gmail.com
Guest
Posts: n/a
 
      07-24-2012
On Tuesday, July 24, 2012 2:29:19 PM UTC+2, Laszlo Nagy wrote:
> On 2012-07-24 14:17, (E-Mail Removed) wrote:
> > 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
> It is not a direct solution to your problem, but can you save the value
> of os.path.dirname(__file__) into another variable?



That might be a workaround that I'm seriously pondering as well.

Thank you.

Ian.

(sorry for google messing up my posts)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Daemon loses __file__ reference after a while. ivdneut@gmail.com Python 8 07-24-2012 08:08 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Floris Bruynooghe Python 1 03-24-2009 02:58 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Jean-Paul Calderone Python 0 03-20-2009 01:02 PM
__file__ vs __FILE__ klenwell Python 11 11-05-2007 06:50 PM
Daemon Win32::Daemon; ph1975@gmail.com Perl Misc 0 09-07-2006 10:58 AM



Advertisments