Skip to content

Commit 962bdea

Browse files
dchevellpablogsal
authored andcommitted
bpo-35715: Liberate return value of _process_worker (GH-11514)
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.
1 parent 9c68543 commit 962bdea

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/concurrent/futures/process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def _process_worker(call_queue, result_queue, initializer, initargs):
235235
_sendback_result(result_queue, call_item.work_id, exception=exc)
236236
else:
237237
_sendback_result(result_queue, call_item.work_id, result=r)
238+
del r
238239

239240
# Liberate the resource as soon as possible, to avoid holding onto
240241
# open files or shared memory that is not needed anymore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Librates the return value of a ProcessPoolExecutor _process_worker after it's no longer needed to free memory

0 commit comments

Comments
 (0)