470,618 Members | 1,710 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,618 developers. It's quick & easy.

None module reference

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
Jul 19 '05 #1
2 1275

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

Jul 19 '05 #2
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
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Grant D. Watson | last post: by
4 posts views Thread by Brad Tilley | last post: by
15 posts views Thread by Ron Adam | last post: by
17 posts views Thread by Jan Danielsson | last post: by
17 posts views Thread by Paul Helmuth | last post: by
6 posts views Thread by Steven D'Aprano | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.