diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-03-24 13:45:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 13:45:34 (GMT) |
commit | cc3331fec8b7a61c3f06c097eac85bfa38490758 (patch) | |
tree | e4c49798dd88112cd4e96ce19d110848d5216e61 /Lib/multiprocessing | |
parent | 90eafdb1546604c0e9bc207723484b6816570cfe (diff) | |
download | cpython-cc3331fec8b7a61c3f06c097eac85bfa38490758.zip cpython-cc3331fec8b7a61c3f06c097eac85bfa38490758.tar.gz cpython-cc3331fec8b7a61c3f06c097eac85bfa38490758.tar.bz2 |
bpo-29861: release references to multiprocessing Pool tasks (#743) (#800)
* bpo-29861: release references to multiprocessing Pool tasks (#743)
* bpo-29861: release references to multiprocessing Pool tasks
Release references to tasks, their arguments and their results as soon
as they are finished, instead of keeping them alive until another task
arrives.
* Comments in test
(cherry picked from commit 8988945cdc27ffa86ba8c624e095b51c459f5154)
* Fix Misc/NEWS (hopefully)
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/pool.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py index ffdf426..ae8cec4 100644 --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -128,6 +128,8 @@ def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None, util.debug("Possible encoding error while sending result: %s" % ( wrapped)) put((job, i, (False, wrapped))) + + task = job = result = func = args = kwds = None completed += 1 util.debug('worker exiting after %d tasks' % completed) @@ -402,10 +404,11 @@ class Pool(object): if set_length: util.debug('doing set_length()') set_length(i+1) + finally: + task = taskseq = job = None else: util.debug('task handler got sentinel') - try: # tell result handler to finish when cache is empty util.debug('task handler sending sentinel to result handler') @@ -445,6 +448,7 @@ class Pool(object): cache[job]._set(i, obj) except KeyError: pass + task = job = obj = None while cache and thread._state != TERMINATE: try: @@ -461,6 +465,7 @@ class Pool(object): cache[job]._set(i, obj) except KeyError: pass + task = job = obj = None if hasattr(outqueue, '_reader'): util.debug('ensuring that outqueue is not full') |