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

Timeout while using vscode debugger with any program which spawns a process #1271

Open
mmohdnowfal opened this issue Apr 12, 2023 · 10 comments
Labels
bug Something isn't working P2

Comments

@mmohdnowfal
Copy link

mmohdnowfal commented Apr 12, 2023

Environment data

  • debugpy version: 1.6.6
  • OS and version: Mac ventura 13.3
  • Python version : 3.10.9
  • Using VS Code or Visual Studio:
    VS Code
    Version: 1.77.2 (Universal)
    Commit: e344f1f539a80912a0e9357cec841f36ce97a4e2
    Date: 2023-04-06T10:12:31.126Z
    Electron: 19.1.11
    Chromium: 102.0.5005.196
    Node.js: 16.14.2
    V8: 10.2.154.26-electron.0
    OS: Darwin arm64 22.4.0
    Sandboxed: No

Actual behavior

This issue is similar to what is reported here.
But this time, it appears to be the issue is while using vscode debugger with any program which internally uses os.execv

We use a library called Unicon, for creating a connection to any remote device via ssh.
This library internally uses os.execv, which looks like has a conflict with debugpy(pyadev_monkey.py)

For every new process created using the above library, there is a delay of 5+ seconds and this delays the debugging process and affect the developer productivity time

Expected behavior

Should spawn the process wihout any delay

Steps to reproduce:

  1. Install the unicon library
    pip install pyats unicon
  2. Create the below data and python file
# Example
# -------
#
#   a simple pyATS testbed YAML file

devices:
    csr1000v-1:
        type: router
        os: iosxe
        credentials:
            default:
                password: foo
                username: foo
            enable:
                password: foo
        connections:
            cli:
                protocol: ssh
                ip: 168.10.1.35
  1. Create a python script
from pyats.topology import loader

testbed = loader.load('my-testbed.yaml')

device = testbed.devices['csr1000v-1']

device.connect()
device.execute('show version')

More info: https://developer.cisco.com/docs/unicon/
6. Run the debug mode

@mmohdnowfal
Copy link
Author

mmohdnowfal commented Apr 12, 2023

Adding the below workaround to the microsoft python debugpy temporarily disables the issue.
~/.vscode/extensions/ms-python.python-2023.6.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py

Please provide a permanent solution to this

Screenshot 2023-04-12 at 3 49 22 PM

@int19h
Copy link
Contributor

int19h commented Apr 12, 2023

It's not a conflict; it's an intentional detour of execv to enable debugging of Python subprocesses.

It doesn't seem to be affecting our multiproc tests - is this specific to Unicon?

@int19h int19h added the bug Something isn't working label Apr 12, 2023
@mmohdnowfal
Copy link
Author

mmohdnowfal commented Apr 13, 2023

It's not a conflict; it's an intentional detour of execv to enable debugging of Python subprocesses.

It doesn't seem to be affecting our multiproc tests - is this specific to Unicon?

As of now it can be reproduced with Unicon. Ideally we should not see any delay while interacting with the process

This is what I see the logs , and every thing start working normally after this delay

2023-04-13 14:09:15,085: %UNICON-INFO: +++ connection to spawn: telnet x.x.x.x 2006, id: 139895617230832 +++
5.01s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.03s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.03s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - 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
5.01s - 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
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - 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
5.02s - 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
5.01s - 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
5.01s - 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
5.01s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - 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
5.01s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - 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
5.03s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.04s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Trying x.x.x.x...
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Trying x.x.x.x...
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Trying x.x.x.x...
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Trying x.x.x.x...
Trying x.x.x.x...
5.02s - pydevd: Sending message related to process being replaced timed-out after 5 seconds

@mmohdnowfal
Copy link
Author

Any comments on how to resolve this

@mmohdnowfal
Copy link
Author

Any update on this issue, many of our team members are facing this issue

@int19h
Copy link
Contributor

int19h commented Oct 25, 2023

To clarify, do you actually need subprocess debugging in your scenario? If you just want to debug the main process, setting "subProcess":false in your debug config will disable all the process creation detouring logic.

@mmohdnowfal
Copy link
Author

mmohdnowfal commented Nov 7, 2023

Yes we use subprocess. Ours is an test framework which triggers testcases using subprocesss. And our main interest is debugging these testcases
So using "subprocess":false will not help

@judej judej added the P2 label Jan 3, 2024
@sstaley-hioscar
Copy link

This has broken my debugging process and yes, I need to be able to debug a subprocess. Will try to work around for now. It would be nice to set my own timeout.

@bernardo-suez
Copy link

Any news on this? It has been a problem for me too.

@jose-cubero
Copy link

I am facing the same issue when trying to debug a script that uses joblib.Parallel. The work-around "subprocess":false does not work for me.

@judej judej assigned debonte and unassigned debonte Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2
Projects
None yet
Development

No branches or pull requests

7 participants