On 10 Mar 2010, at 23:32, Nick Coghlan wrote:

Brian Quinlan wrote:
Getting rid of the process-global state like this simplifies testing
(both testing of the executors themselves and of application code
which uses them).  It also eliminates the unpleasant interpreter
shutdown/module globals interactions that have plagued a number of
stdlib systems that keep global state.

I'm not sure what you mean, could you clarify?

Assuming your question refers to the second sentence, Jean-Paul is
referring to a trick of the CPython interpreter when it terminates. To
maximise the chances of objects being deleted properly rather than just
dumped from memory when the process exits, module dictionaries are
filled with None values before the interpreter shuts down.

This can cause weirdness (usually intermittent name errors during
shutdown) when __del__ methods directly or indirectly reference module
globals.


Ah. I'm familiar with this problem. My approach was to install an exit handler that ensures that all pending futures are complete and all threads and processes exit before allowing the interpreter to exit.

Cheers,
Brian

One of the easiest ways to avoid that is to put the state on a singleton
object, then give the affected classes a reference to that object.

Cheers,
Nick.

P.S. This problem is actually the reason we don't have a context manager
for temporary directories yet. Something that should have been simple
became a twisty journey down the rabbit hole:
http://bugs.python.org/issue5178

--
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/brian%40sweetapp.com

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to