-
Notifications
You must be signed in to change notification settings - Fork 142
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
subprocess.check_output hangs when gevent support is enabled and subprocess is monkey patched #1005
Comments
I couldn't reproduce this here. Can you send the logs for the run? i.e.:
|
As a note, I was able to reproduce showing the messages:
But the debugging proceeds normally and nothing hangs (and a breakpoint can be hit in |
Note: I'm investigating why those messages appear in the first place (that's not expected in this case). |
The issue is that |
I will do some additional debugging to get you an updated code snippet. In my case it seems to be messing with my fastapi server starting. To be fair, we are doing some patching to make it work with gevent but those code paths don't seem to be the ones affected. |
The issue here is that we are doing 8 Here is the code to reproduce:
and the output:
|
Yes, this is really an issue (I'm still working on this item). What happens is that the fork is done and the monkey-patching is all in place so, in the child process the debugger tries to send a message where the debugger isn't really present before an execv, but this will never work in this case (because the debugger threads aren't really live in that process), so, the practical effect is that any execv afterwards will try to send that message and it'll always timeout (so, it'll sleep for 5 seconds). I'm working on a fix... |
As a note, as a workaround you can ask the debugger not to attach to subprocesses automatically (by setting |
I have a preliminary fix just for this use case (when you're launching non-python processes with gevent). If you want you can apply this change locally. See: fabioz@00834a5 It's not final (at the very minimum I still need to add tests and I want to test the functionality when a subprocess which is python -- and thus the debugger needs to be working in the child process -- while using gevent too), but you should be able to apply the fix locally in the meanwhile. To apply the fix locally make a debug run with the contents below, open the file printed and do the changes from that commit link (as it's a 2-line change it should be pretty straightforward).
|
Verified the fix worked for me thanks! |
If this is the same issue I'm thinking of, I noticed that python debug points could not be hit on the most recent version of vscode, but they were working in 1.61.2 (sep '21). Something changed after 1.61 that broke that (I'm using gunicorn with gevents on mac). Just spent the past few minutes comparing vscode versions, works in 1.61.2 and not on the latest. |
@dre-gonzalez-l7 I think this fix isn't really in the latest release... if you manually apply the change noted in: #1005 (comment), does it work for you? |
@fabioz I'll have to set aside some time to try it out, not sure I'll be able to get to it (it's been a while) |
@fabioz Can confirm, the code change fixed the issue presented here. I still can't hit python breakpoints though (I'm using Intel mac; I'm told debug breakpoints work on M1) |
Possibly related on Stack Overflow: VSCode pydevd: Sending message related to process being replaced timed-out after 5 seconds |
I'm getting this all the time in my notebooks when using skopt and lgbm, whenever I had launched the debugger at some point in my session. Most of the time I have to restart the kernel because these messages clutter everything. Which makes the debugger kind of useless because I don't want to lose the state of my kernel. |
@fabioz sorry for insisting but as per #1005 (comment), which is still the case, I think this shouldn't be closed. Many times I've to restart a kernel after debugging because of the maddening amount of messages from pydev. |
Environment data
minimal launch.json to reproduce
Code to reproduce
output
Turning off subprocess monkey patching fixes it and allows the program to continue.
The text was updated successfully, but these errors were encountered: