Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage with Python3.8b2 breaks multiprocessing #828

Closed
nitzmahone opened this issue Jul 25, 2019 · 3 comments
Closed

coverage with Python3.8b2 breaks multiprocessing #828

nitzmahone opened this issue Jul 25, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@nitzmahone
Copy link

nitzmahone commented Jul 25, 2019

Describe the bug
When using coverage with concurrency=multiprocessing under Python3.8b2, forked processes don't fully init. The child worker process starts, and the process init code runs, but the actual Process run target never executes. The minimal repro sample below works fine under other released versions of Python.

To Reproduce
How can we reproduce the problem? Please be specific.

  1. What version of Python are you running? 3.8b2
  2. What versions of what packages do you have installed? coverage==4.5.3
  3. What code are you running?

repro.py

import multiprocessing


class Worker(multiprocessing.Process):
    def __init__(self, result_queue, input):
        print("in child init")
        super(Worker, self).__init__()
        self._rq = result_queue
        self._input = input
        print("child init done")

    def run(self):
        print("in child run")
        self._rq.put("worker ran with {0}".format(self._input))


rq = multiprocessing.Queue()

w = Worker(rq, "hello")
w.start()

print("worker pid is {0}, waiting for results...".format(w.pid))

results = rq.get()
print(results)
print("done")
  1. What commands did you run? coverage3 run --concurrency=multiprocessing repro.py

Expected behavior
child workloads complete, "done" is printed (along with some debug info)

Additional context
We started hitting this recently in Ansible's nightly coverage runs (which include Python 3.8 prereleases as a canary)...

@nitzmahone
Copy link
Author

an even tinier repro (might make a nice test case ;) ):

import multiprocessing


def do_stuff(result_queue):
    result_queue.put("yay, worker ran")


rq = multiprocessing.Queue()
multiprocessing.Process(target=do_stuff, args=[rq]).start()

print("waiting for results...")
print(rq.get())
print("done")

@nedbat
Copy link
Owner

nedbat commented Jul 29, 2019

Thanks, this is fixed in version 4.5.4, and 5.0a5.

@samdoran
Copy link

@nedbat Thank you for the quick fix. This has been causing us trouble for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants