Skip to content

Commit 6f94bbf

Browse files
miss-islingtonz764969689arhadthedevgpshead
authored
[3.11] gh-104536: Improve multiprocessing.process._cleanup logic (GH-104537) (#104737)
Fix a race condition in the internal `multiprocessing.process` cleanup logic that could manifest as an unintended `AttributeError` when calling `BaseProcess.close()`. (cherry picked from commit ef5d00a) Co-authored-by: Luccccifer <[email protected]> Co-authored-by: Oleg Iarygin <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
1 parent e95ca78 commit 6f94bbf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/multiprocessing/process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def parent_process():
6161
def _cleanup():
6262
# check for processes which have finished
6363
for p in list(_children):
64-
if p._popen.poll() is not None:
64+
if (child_popen := p._popen) and child_popen.poll() is not None:
6565
_children.discard(p)
6666

6767
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a race condition in the internal :mod:`multiprocessing.process` cleanup
2+
logic that could manifest as an unintended ``AttributeError`` when calling
3+
``process.close()``.

0 commit comments

Comments
 (0)