Skip to content

Subprocess and json flags don't work together #601

@JRoper18

Description

@JRoper18

Specifying both the json and subprocess flags will only print out the dump of the root process and will ignore subprocesses. For example, when running the following python program:

import time
from multiprocessing import Process
def work():
    time.sleep(1000)

for _ in range(10):
    p = Process(target=work, daemon=True)
    p.start()

time.sleep(1000)

And then running:

py-spy dump -js --pid <pid>

Will only return the dump of the root process:

[
  {
    "pid": 16866,
    "thread_id": 140634802636608,
    "thread_name": "MainThread",
    "os_thread_id": 16866,
    "active": false,
    "owns_gil": false,
    "frames": [
      {
        "name": "<module>",
        "filename": "main.py",
        "module": null,
        "short_filename": "main.py",
        "line": 10,
        "locals": null
      }
    ],
    "process_info": null
  }
]

I would expect it to return dumps of all the processes/threads, instead.

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