Message358232
I'm trying to evaluate process' state between two "sibling" processes (processes created by the same parent process); using the .is_alive() and exitcode to evaluate whether a process has been init'd, started, finished successfully or unsuccessfully.
The reference to one process is passed to the other and I'd like to call .is_alive(). This raises the following assertion error:
Process C-2:
Traceback (most recent call last):
File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/home/timms/.PyCharm2019.2/config/scratches/is_alive_method.py", line 59, in run
print("brother - ",self.brother.state)
File "/home/timms/.PyCharm2019.2/config/scratches/is_alive_method.py", line 16, in state
if self.is_alive():
File "/usr/lib/python3.7/multiprocessing/process.py", line 151, in is_alive
assert self._parent_pid == os.getpid(), 'can only test a child process'
AssertionError: can only test a child process
It's obvious that the assertion fails given the family structure of the processes. Overwriting the is_alive() method in my own process class appears to produce my desired output behaviour - with assertion and discarding self removed (see attachment).
Is there something fundamental to how process' operate that I should be weary of? I understand that is_alive also joins itself if possible; is that the sole reason for the assertion? Could a method that mirrors is_alive() without the assertion and discard method work with the desired intention I've described above? |
|
Date |
User |
Action |
Args |
2019-12-10 23:22:54 | matttimms | set | recipients:
+ matttimms |
2019-12-10 23:22:54 | matttimms | set | messageid: <1576020174.84.0.795117240122.issue39021@roundup.psfhosted.org> |
2019-12-10 23:22:54 | matttimms | link | issue39021 messages |
2019-12-10 23:22:54 | matttimms | create | |
|