Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > None module reference

Reply
Thread Tools

None module reference

 
 
Stefan Seefeld
Guest
Posts: n/a
 
      05-22-2005
hello,

I'v run into a bug that I find hard to understand:

In a python module of mine I import system modules
('sys', say) and then use them from within some functions.

However, during program termination I'm calling
one such function and the module reference ('sys')
is 'None' !

What does that mean ? Have those modules already
been unloaded ? If so, why, given that my
current module still references them ?

Any help is highly appreciated,

Stefan
 
Reply With Quote
 
 
 
 
Kay Schluehr
Guest
Posts: n/a
 
      05-22-2005

Stefan Seefeld wrote:
> hello,
>
> I'v run into a bug that I find hard to understand:
>
> In a python module of mine I import system modules
> ('sys', say) and then use them from within some functions.
>
> However, during program termination I'm calling
> one such function and the module reference ('sys')
> is 'None' !


Do You register Your function using atexit() ?

This works perfectly fine and as expected for me. I would wonder if the
interpreter was shut down and tries to execute a cleanup thereafter.

Checkout following example code. You may also have a look at the
/lib/atexit.py module see how it works.

import atexit
import sys
def foo():
print sys

atexit.register(foo)

Ciao,
Kay

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      05-23-2005
Stefan Seefeld wrote:
> In a python module of mine I import system modules
> ('sys', say) and then use them from within some functions.
>
> However, during program termination I'm calling
> one such function and the module reference ('sys')
> is 'None' !


Are you running any daemon threads? This can generally happen when a
daemon thread continues to access module globals during the interpreter
shutdown sequence. At one stage all globals in all modules are rebound
to None, and there's a chance some of your daemon thread code will
execute just as this is occurring, resulting in that kind of error message.

-Peter
 
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
DataGrid - BorderStyle="None" and BorderWidth="None" doesn't work for Firefox David Freeman ASP .Net 8 02-16-2011 11:03 AM
Re: <var> is None vs. <var> == None Steve Holden Python 9 01-26-2009 09:10 PM
<var> is None vs. <var> == None Gerald Britton Python 7 01-24-2009 09:02 AM
testing for valid reference: obj vs. None!=obs vs. obj is not None alf Python 9 12-09-2006 05:00 AM
Is there a built-in method for transforming (1,None,"Hello!") to 1,None,"Hello!"? Daniel Crespo Python 5 11-13-2005 12:52 PM



Advertisments