Expected python bug using multiprocessing and inheritance
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
This is a bug report:
import time
import multiprocessing as mp
class A(object):
def __init__(self, childnodes, **kwargs) -> None:
self._childnodes = childnodes
self._kwargs = kwargs
def process(self, datablock, meta):
print("Hello")
time.sleep(1)
print("world")
class B(A):
def process(self, datablock, meta):
print("before")
mp.Process(target=super().process, args=(self, datablock, meta)).start()
print("after")
if __name__ == "__main__":
b = B([1,2,3])
b.process([4,5,6], {'foo':42})
This seems to run forerever which is not expected. Reason seems to be that that somehow, super().process actually calls B.process instead of A.process in the subprocess. This is not expected behaviour. As additional evidence towards that, the program behaviour can be corrected by changing
mp.Process(target=super().process, args=(self, datablock, meta)).start()`meta)).start()
with
mp.Process(target=A.process, args=(self, datablock, meta)).start()
Machine:
MacBook Pro (16-inch, 2021)
MacOS Monteray 12.5
Chip: Apple M1 Max
Python version: 3.9.12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied reproducer on Python 3.9.12 and tracing how multiprocessing handles the bound super().process target in the child process. Compare this with the explicit A.process target; done means the superclass call no longer recurses while retaining the expected multiprocessing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100