You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project that uses threading.Thread and multiprocessing.Process for handling concurrent tasks. While under certain circumstances, there is the possibility that when I try new a Process() instance and call the Process.start() function, an error would occur: AttributeError: 'NoneType' object has no attribute 'poll'
I tried debugging my project and found that under the multiprocessing.process module a global variable _children is used for managing all child processes, the variable is not thread-safe and the error would occur occasionally. I made a simple test code with minor modification on the multiprocessing.process
defclose(self):
''' Close the Process object. This method releases resources held by the Process object. It is an error to call this method if the child process is still running. '''ifself._popenisnotNone:
ifself._popen.poll() isNone:
raiseValueError("Cannot close a process while it is still running. ""You should first call join() or terminate().")
self._popen.close()
self._popen=Noneimporttimetime.sleep(5)
delself._sentinel_children.discard(self)
self._closed=True
I simply add time.sleep() for BaseProcess.close() class and now every time I run the test.py, the error would occur.
Your environment
CPython versions tested on: python 3.7
Operating system and architecture: windows 10 or linux el7
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]>
…thonGH-104537)
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]>
…H-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]>
gtopper
added a commit
to gtopper/taos-ws-py-wrapper
that referenced
this issue
Oct 13, 2024
Bug report
I have a project that uses threading.Thread and multiprocessing.Process for handling concurrent tasks. While under certain circumstances, there is the possibility that when I try new a
Process()
instance and call theProcess.start()
function, an error would occur:AttributeError: 'NoneType' object has no attribute 'poll'
I tried debugging my project and found that under the
multiprocessing.process
module a global variable_children
is used for managing all child processes, the variable is not thread-safe and the error would occur occasionally. I made a simple test code with minor modification on themultiprocessing.process
test.py
multiprocessing.process.py class BaseProcess
I simply add
time.sleep()
forBaseProcess.close()
class and now every time I run thetest.py,
the error would occur.Your environment
Linked PRs
multiprocessing.process._cleanup
logic #104537multiprocessing.process._cleanup
logic (GH-104537) #104737The text was updated successfully, but these errors were encountered: