New submission from Matt <matthewti...@live.com.au>:

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?

----------
files: is_alive_method.py
messages: 358232
nosy: matttimms
priority: normal
severity: normal
status: open
title: multiprocessing is_alive() between children processes
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48770/is_alive_method.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39021>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to