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
=====

View File

@ -77,7 +77,7 @@ def _python_exit():
for t, q in items:
q.put(None)
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.
# 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
# X.
for p in processes:
p.join()
p.join(sys.maxint)
call_queue.close()
return
del executor
@ -347,7 +347,7 @@ class ProcessPoolExecutor(_base.Executor):
# Wake up queue management thread
self._result_queue.put(None)
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
# objects that use file descriptors.
self._queue_management_thread = None

View File

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

View File

@ -1,4 +1,11 @@
#!/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 = {}
try:
@ -8,7 +15,7 @@ except ImportError:
from distutils.core import setup
setup(name='futures',
version='3.0.3',
version='3.0.4',
description='Backport of the concurrent.futures package from Python 3.2',
author='Brian Quinlan',
author_email='brian@sweetapp.com',