startover / pythonfutures

Automatically exported from code.google.com/p/pythonfutures
Other
0 stars 0 forks source link

atexit hooks are wrongly used #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I do not know how to reproduce with small program, but when using tornado 
tests, I receive that:

--------------------------------
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/mmarkk/.local/lib/python2.7/site-packages/concurrent/futures/process.py", line 82, in _python_exit
    items = list(_threads_queues.items())
AttributeError: 'NoneType' object has no attribute 'items'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/mmarkk/.local/lib/python2.7/site-packages/concurrent/futures/thread.py", line 41, in _python_exit
    items = list(_threads_queues.items())
AttributeError: 'NoneType' object has no attribute 'items'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/mmarkk/.local/lib/python2.7/site-packages/concurrent/futures/thread.py", line 41, in _python_exit
    items = list(_threads_queues.items())
AttributeError: 'NoneType' object has no attribute 'items'
---------------------------

But this problem is easily fixed with that:

--- process.py  2015-01-21 15:27:49.458086156 +0500
+++ process.py.new  2015-01-21 15:28:10.906259116 +0500
@@ -76,7 +76,7 @@
 _threads_queues = weakref.WeakKeyDictionary()
 _shutdown = False

-def _python_exit():
+def _python_exit(_threads_queues=_threads_queues):
     global _shutdown
     _shutdown = True
     items = list(_threads_queues.items())

!!!!! and exactly the same for threads.py !!!!

What the hell? I do not know how the _threads_queues may become None.

Original issue reported on code.google.com by socketp...@gmail.com on 21 Jan 2015 at 10:29