Skip to content

Multiprocessing Deadlock with v0.4.0 #732

@mlucool

Description

@mlucool

Hi,

The following causes py-spy to hang randomly, both with --subprocess and without. When we looked at the process, it seems like one thread is waiting to to recv from a channel.

In this reproducer, you'll see that one of the samples will cause it to hang forever.

$ cat py_spy_crash.py
#!/usr/bin/env python3
from concurrent.futures import ProcessPoolExecutor
from scipy.signal import lfilter
for ix in range(2):
    with ProcessPoolExecutor(1) as executor:
        executor.submit(lfilter, [1.0], [1.0], [1.0]).result()
    print(f"done with {ix=}", flush=True)
$ for i in `seq 100`; do time -p py-spy record -o /dev/null --subprocesses -- ./py_spy_crash.py; done

You can also run it without --subprocesses and see that this happens.

$ for i in `seq 100`; do time -p py-spy record -o /dev/null -- ./py_spy_crash.py; done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions