]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35715: Liberate return value of _process_worker (GH-11514)
authorDave Chevell <chevell@gmail.com>
Sat, 16 Mar 2019 22:28:51 +0000 (09:28 +1100)
committerPablo Galindo <Pablogsal@gmail.com>
Sat, 16 Mar 2019 22:28:51 +0000 (22:28 +0000)
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.

Lib/concurrent/futures/process.py
Misc/NEWS.d/next/Library/2019-01-11-08-47-58.bpo-35715.Wi3gl0.rst [new file with mode: 0644]

index ce7d642b098a71f5150e64bd4d16c1f2f804ff47..9b85e7f337698e874e086fcc3f4369549607a63e 100644 (file)
@@ -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
diff --git a/Misc/NEWS.d/next/Library/2019-01-11-08-47-58.bpo-35715.Wi3gl0.rst b/Misc/NEWS.d/next/Library/2019-01-11-08-47-58.bpo-35715.Wi3gl0.rst
new file mode 100644 (file)
index 0000000..0c1ec6b
--- /dev/null
@@ -0,0 +1 @@
+Librates the return value of a ProcessPoolExecutor _process_worker after it's no longer needed to free memory
\ No newline at end of file