Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25981 > unrolled thread

Daemon loses __file__ reference after a while

Started by"ivdneut@gmail.com" <ivdneut@gmail.com>
First post2012-07-24 05:17 -0700
Last post2012-07-24 05:44 -0700
Articles 4 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Daemon loses __file__ reference after a while "ivdneut@gmail.com" <ivdneut@gmail.com> - 2012-07-24 05:17 -0700
    Re: Daemon loses __file__ reference after a while Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-24 14:29 +0200
      Re: Daemon loses __file__ reference after a while "ivdneut@gmail.com" <ivdneut@gmail.com> - 2012-07-24 05:44 -0700
      Re: Daemon loses __file__ reference after a while "ivdneut@gmail.com" <ivdneut@gmail.com> - 2012-07-24 05:44 -0700

#25981 — Daemon loses __file__ reference after a while

From"ivdneut@gmail.com" <ivdneut@gmail.com>
Date2012-07-24 05:17 -0700
SubjectDaemon loses __file__ reference after a while
Message-ID<33df007b-6953-4606-871c-7a9b995739f2@googlegroups.com>
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 if it didn't show up, which as far as I can determine, it didn't.)

[toc] | [next] | [standalone]


#25983

FromLaszlo Nagy <gandalf@shopzeus.com>
Date2012-07-24 14:29 +0200
Message-ID<mailman.2532.1343132964.4697.python-list@python.org>
In reply to#25981
On 2012-07-24 14:17, ivdneut@gmail.com 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?

[toc] | [prev] | [next] | [standalone]


#25986

From"ivdneut@gmail.com" <ivdneut@gmail.com>
Date2012-07-24 05:44 -0700
Message-ID<mailman.2535.1343133866.4697.python-list@python.org>
In reply to#25983
On Tuesday, July 24, 2012 2:29:19 PM UTC+2, Laszlo Nagy wrote:
> On 2012-07-24 14:17, ivdneut@gmail.com wrote:
> &gt; Hello all,
> &gt;
> &gt; I have a deamon process that runs for some considerable time (weeks) without any problems. At some point it starts throwing the following exception:
> &gt;
> &gt;    File &quot;/some/path/scheduler.py&quot;, line 376, in applyrule
> &gt;      result = execrule(rule_code)
> &gt;    File &quot;/some/path/scheduler.py&quot;, line 521, in execrule
> &gt;      rulepath = os.path.dirname(__file__)+&quot;/&quot;+&#39;/&#39;.join(rule[&#39;modules&#39;])+&quot;/&quot;+rule[&#39;rulename&#39;]
> &gt; NameError: name &#39;__file__&#39; 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)

[toc] | [prev] | [next] | [standalone]


#25988

From"ivdneut@gmail.com" <ivdneut@gmail.com>
Date2012-07-24 05:44 -0700
Message-ID<c9a4e2f7-6413-4737-bb9e-c763a305895b@googlegroups.com>
In reply to#25983
On Tuesday, July 24, 2012 2:29:19 PM UTC+2, Laszlo Nagy wrote:
> On 2012-07-24 14:17, ivdneut@gmail.com wrote:
> &gt; Hello all,
> &gt;
> &gt; I have a deamon process that runs for some considerable time (weeks) without any problems. At some point it starts throwing the following exception:
> &gt;
> &gt;    File &quot;/some/path/scheduler.py&quot;, line 376, in applyrule
> &gt;      result = execrule(rule_code)
> &gt;    File &quot;/some/path/scheduler.py&quot;, line 521, in execrule
> &gt;      rulepath = os.path.dirname(__file__)+&quot;/&quot;+&#39;/&#39;.join(rule[&#39;modules&#39;])+&quot;/&quot;+rule[&#39;rulename&#39;]
> &gt; NameError: name &#39;__file__&#39; 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)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web