diff options
| author | Luccccifer <lukezhang764@gmail.com> | 2023-05-22 03:48:57 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-22 03:48:57 (GMT) |
| commit | ef5d00a59207a63c6d5ae0d5d44054847d1bf3b5 (patch) | |
| tree | 5256f13fde2d7dee7ccc17fc64df6abf62ef626c /Lib/multiprocessing/process.py | |
| parent | b9c807a260f63284f16e25b5e98e18191f61a05f (diff) | |
| download | cpython-ef5d00a59207a63c6d5ae0d5d44054847d1bf3b5.zip cpython-ef5d00a59207a63c6d5ae0d5d44054847d1bf3b5.tar.gz cpython-ef5d00a59207a63c6d5ae0d5d44054847d1bf3b5.tar.bz2 | |
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 <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Lib/multiprocessing/process.py')
| -rw-r--r-- | Lib/multiprocessing/process.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py index c03c859..271ba3f 100644 --- a/Lib/multiprocessing/process.py +++ b/Lib/multiprocessing/process.py @@ -61,7 +61,7 @@ def parent_process(): def _cleanup(): # check for processes which have finished for p in list(_children): - if p._popen.poll() is not None: + if (child_popen := p._popen) and child_popen.poll() is not None: _children.discard(p) # |
