Made thread joins interruptible by specifying a timeout (fixes #25)

This commit is contained in:
Alex Grönholm 2016-01-18 02:38:41 +02:00
parent b60cc06451
commit 515263aa95
4 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,9 @@
3.0.4
=====
- Fixed inability to forcibly terminate the process if there are pending workers
3.0.3 3.0.3
===== =====

View File

@ -77,7 +77,7 @@ def _python_exit():
for t, q in items: for t, q in items:
q.put(None) q.put(None)
for t, q in items: for t, q in items:
t.join() t.join(sys.maxint)
# Controls how many more calls than processes will be queued in the call queue. # Controls how many more calls than processes will be queued in the call queue.
# A smaller number will mean that processes spend more time idle waiting for # A smaller number will mean that processes spend more time idle waiting for
@ -232,7 +232,7 @@ def _queue_management_worker(executor_reference,
# some multiprocessing.Queue methods may deadlock on Mac OS # some multiprocessing.Queue methods may deadlock on Mac OS
# X. # X.
for p in processes: for p in processes:
p.join() p.join(sys.maxint)
call_queue.close() call_queue.close()
return return
del executor del executor
@ -347,7 +347,7 @@ class ProcessPoolExecutor(_base.Executor):
# Wake up queue management thread # Wake up queue management thread
self._result_queue.put(None) self._result_queue.put(None)
if wait: if wait:
self._queue_management_thread.join() self._queue_management_thread.join(sys.maxint)
# To reduce the risk of openning too many files, remove references to # To reduce the risk of openning too many files, remove references to
# objects that use file descriptors. # objects that use file descriptors.
self._queue_management_thread = None self._queue_management_thread = None

View File

@ -36,7 +36,7 @@ def _python_exit():
for t, q in items: for t, q in items:
q.put(None) q.put(None)
for t, q in items: for t, q in items:
t.join() t.join(sys.maxint)
atexit.register(_python_exit) atexit.register(_python_exit)
@ -130,5 +130,5 @@ class ThreadPoolExecutor(_base.Executor):
self._work_queue.put(None) self._work_queue.put(None)
if wait: if wait:
for t in self._threads: for t in self._threads:
t.join() t.join(sys.maxint)
shutdown.__doc__ = _base.Executor.shutdown.__doc__ shutdown.__doc__ = _base.Executor.shutdown.__doc__

View File

@ -1,4 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
from warnings import warn
import sys
if sys.version_info[0] > 2:
warn('This backport is meant only for Python 2.\n'
'Python 3 users do not need it, as the concurrent.futures '
'package is available in the standard library.')
extras = {} extras = {}
try: try:
@ -8,7 +15,7 @@ except ImportError:
from distutils.core import setup from distutils.core import setup
setup(name='futures', setup(name='futures',
version='3.0.3', version='3.0.4',
description='Backport of the concurrent.futures package from Python 3.2', description='Backport of the concurrent.futures package from Python 3.2',
author='Brian Quinlan', author='Brian Quinlan',
author_email='brian@sweetapp.com', author_email='brian@sweetapp.com',