Skip to content

Commit

Permalink
bpo-35715: Liberate return value of _process_worker (GH-11514)
Browse files Browse the repository at this point in the history
ProcessPoolExecutor workers will hold the return value of their last task in memory until the next task is received. Since the return value has already been propagated to the parent process's Future (or has been discarded by this point), the object can be safely released.
  • Loading branch information
dchevell authored and pablogsal committed Mar 16, 2019
1 parent 9c68543 commit 962bdea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/concurrent/futures/process.py
Expand Up @@ -235,6 +235,7 @@ def _process_worker(call_queue, result_queue, initializer, initargs):
_sendback_result(result_queue, call_item.work_id, exception=exc)
else:
_sendback_result(result_queue, call_item.work_id, result=r)
del r

# Liberate the resource as soon as possible, to avoid holding onto
# open files or shared memory that is not needed anymore
Expand Down
@@ -0,0 +1 @@
Librates the return value of a ProcessPoolExecutor _process_worker after it's no longer needed to free memory

0 comments on commit 962bdea

Please sign in to comment.