summaryrefslogtreecommitdiffstats
path: root/Lib/concurrent
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-11-03 13:36:01 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-11-03 13:36:01 (GMT)
commit6b973747f3c5e31afd89f6a7d79bc9f3f1628710 (patch)
tree10127b702286a312c859d4bf9922716f8ad402bf /Lib/concurrent
parent0f77bf27ca372655104884bf1e1ecaf014e8a61a (diff)
downloadcpython-6b973747f3c5e31afd89f6a7d79bc9f3f1628710.zip
cpython-6b973747f3c5e31afd89f6a7d79bc9f3f1628710.tar.gz
cpython-6b973747f3c5e31afd89f6a7d79bc9f3f1628710.tar.bz2
Issue #16284: Prevent keeping unnecessary references to worker functions in concurrent.futures ThreadPoolExecutor.
Diffstat (limited to 'Lib/concurrent')
-rw-r--r--Lib/concurrent/futures/process.py4
-rw-r--r--Lib/concurrent/futures/thread.py2
2 files changed, 6 insertions, 0 deletions
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py
index 94e0289..3c20b93 100644
--- a/Lib/concurrent/futures/process.py
+++ b/Lib/concurrent/futures/process.py
@@ -240,6 +240,8 @@ def _queue_management_worker(executor_reference,
"terminated abruptly while the future was "
"running or pending."
))
+ # Delete references to object. See issue16284
+ del work_item
pending_work_items.clear()
# Terminate remaining workers forcibly: the queues or their
# locks may be in a dirty state and block forever.
@@ -264,6 +266,8 @@ def _queue_management_worker(executor_reference,
work_item.future.set_exception(result_item.exception)
else:
work_item.future.set_result(result_item.result)
+ # Delete references to object. See issue16284
+ del work_item
# Check whether we should start shutting down.
executor = executor_reference()
# No more work items can be added if:
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
index 95bb682..f9beb0f 100644
--- a/Lib/concurrent/futures/thread.py
+++ b/Lib/concurrent/futures/thread.py
@@ -63,6 +63,8 @@ def _worker(executor_reference, work_queue):
work_item = work_queue.get(block=True)
if work_item is not None:
work_item.run()
+ # Delete references to object. See issue16284
+ del work_item
continue
executor = executor_reference()
# Exit if: