Skip to content

Commit 716556e

Browse files
author
=
committed
Compatible to python3.6
1 parent a6abec3 commit 716556e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ThreadPoolExecutorPlus/thread.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
else:
2424
raise RuntimeError("We havent decided how many threads should acquire on your platform. Maybe you have to modify source code your self.")
2525

26+
BASE_ABOVE_PY_37 = True if 'BrokenExecutor' in dir(_base) else False
27+
QUEUE_ABOVE_PY_37 = True if 'SipleQueue' in dir(queue) else False
28+
2629
# Workers are created as daemon threads. This is done to allow the interpreter
2730
# to exit when there are still idle threads in a ThreadPoolExecutor's thread
2831
# pool (i.e. shutdown() was not called). However, allowing workers to die with
@@ -178,9 +181,7 @@ class BrokenExecutor(RuntimeError):
178181
"""
179182

180183
# Upward Compatible
181-
_class_brokenexecutor = BrokenExecutor
182-
if 'BrokenExecutor' in dir(_base):
183-
_class_brokenexecutor = _base.BrokenExecutor
184+
_class_brokenexecutor = _base.BrokenExecutor if BASE_ABOVE_PY_37 else BrokenExecutor
184185

185186

186187
class BrokenThreadPool(_class_brokenexecutor):
@@ -218,8 +219,7 @@ def __init__(self, max_workers=None, thread_name_prefix='',
218219
raise TypeError("initializer must be a callable")
219220

220221
self._max_workers = max_workers
221-
# self._work_queue = queue.Queue(max_workers << 6)
222-
self._work_queue = queue.SimpleQueue()
222+
self._work_queue = queue.SimpleQueue() if QUEUE_ABOVE_PY_37 else queue.Queue(max_workers << 6)
223223
self._threads = _CustomWeakSet()
224224
self._broken = False
225225
self._shutdown = False

0 commit comments

Comments
 (0)