Skip to content

Commit ef5d00a

Browse files
z764969689arhadthedevgpshead
authored
gh-104536: Improve multiprocessing.process._cleanup logic (#104537)
Fix a race condition in the internal `multiprocessing.process` cleanup logic that could manifest as an unintended `AttributeError` when calling `BaseProcess.close()`. --------- Co-authored-by: Oleg Iarygin <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
1 parent b9c807a commit ef5d00a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/multiprocessing/process.py

Lines changed: 1 addition & 1 deletion
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
#
Lines changed: 3 additions & 0 deletions
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)