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

Subprocess always waits for client to attach #81

Closed
memeplex opened this issue Mar 21, 2020 · 2 comments
Closed

Subprocess always waits for client to attach #81

memeplex opened this issue Mar 21, 2020 · 2 comments
Labels
bug Something isn't working P0 The issue is important, and should be prioritized for new work.

Comments

@memeplex
Copy link

memeplex commented Mar 21, 2020

Environment data

  • PTVSD version: the one shipped with vscode-python March 2020
  • OS and version: Ubuntu 19.10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.5
  • Using VS Code or Visual Studio: VSCode

Actual behavior

I run this script

import time
import multiprocessing as mp


def f():
    x = 0
    while True:
        x += 1
        print("y")
        time.sleep(0.1)


print("x")
p = mp.Process(target=f)
p.start()
p.join()

with python3 -m debugpy --listen localhost:5678 /tmp/test.py.

I can see "x" but no "y".

Expected behavior

According to your README this should not wait for a client to attach, so the subprocess should immediately start running.

Steps to reproduce:

Run the above script as explained.

@int19h
Copy link
Contributor

int19h commented Mar 22, 2020

This is an interesting point!

The current design does indeed force a wait on any subprocess attached in the same logical session. The reason for that is to treat breakpoints as if they were also a part of that single logical session, with processes working more or less like threads. Which is to say - if you have a breakpoint set on the very first line of code inside the child process about to be spawned (e.g. inside f, in your example), and you step over the statement that spawns it in the parent process, the breakpoint should be hit. Just as it would be hit if you did the same thing with a thread. This requires that child process doesn't run any user code, until the client can connect and tell it what the active breakpoints are.

I think our problem here is that this doesn't really make sense when there are no active client sessions in the current multiproc logical session - i.e. subprocesses should only wait implicitly at spawn if the notification about them was successfully delivered to the client.

@int19h int19h added the bug Something isn't working label Apr 1, 2020
@karthiknadig karthiknadig added the P0 The issue is important, and should be prioritized for new work. label Sep 22, 2020
@int19h int19h changed the title Subprocess seems to always wait for client to attach Subprocess always waits for client to attach Sep 23, 2020
int19h added a commit to int19h/debugpy that referenced this issue Sep 25, 2020
Unblock subprocesses for which no notification could be sent to the client.
int19h added a commit to int19h/debugpy that referenced this issue Sep 25, 2020
Unblock subprocesses for which no notification could be sent to the client.
@int19h int19h closed this as completed in 6e1c756 Sep 25, 2020
@memeplex
Copy link
Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 The issue is important, and should be prioritized for new work.
Projects
None yet
Development

No branches or pull requests

3 participants