Skip to content

subprocess.check_output hangs when gevent support is enabled and subprocess is monkey patched #1005

@reallistic

Description

@reallistic

Environment data

  • debugpy version: 1.6.2
  • OS and version:
    • VS Code 1.69.2 running on Mac OS 12.5
    • Development env - (remote ssh) Ubuntu 18.04.6 (Connected via the Remote SSH plugin)
  • Python version: Python 3.9.13
  • Using VS Code 1.69.2
  • Using ms-python.python-2022.10.1

minimal launch.json to reproduce

{
  
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Example",
            "type": "python",
            "request": "launch",
            "program": "agevent_test.py",
            "console": "integratedTerminal",
            "justMyCode": false,
            "gevent": true,
            "env": {
                "GEVENT_SUPPORT": "True",
            }
        }
  ]
}

Code to reproduce

from gevent import monkey; monkey.patch_all()

import subprocess


if __name__ == "__main__":
    resp = subprocess.check_output("tput -T xterm-256color bold".split()).decode(
        "utf-8"
    )  # nosec
    print(resp)
    print("Done")

output

6.18s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.01s - pydevd: Sending message related to process being replaced timed-out after 5 seconds

Turning off subprocess monkey patching fixes it and allows the program to continue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions