Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

ptvsd hangs on subprocess.Process.join #1036

Closed
sjdv1982 opened this issue Nov 19, 2018 · 3 comments
Closed

ptvsd hangs on subprocess.Process.join #1036

sjdv1982 opened this issue Nov 19, 2018 · 3 comments

Comments

@sjdv1982
Copy link

Environment data

  • PTVSD version: /extensions/ms-python.python-2018.10.1
  • OS and version: Ubuntu 18.04.1
  • Python version (& distribution if applicable, e.g. Anaconda):
    Python 3.6.6, Anaconda 2.7.13, Python 2.7.16
  • Using VS Code or Visual Studio: VS Code

Actual behavior

Subprocess code gets never executed
Subprocess remains alive after 5 seconds
On Python2, the debugged main process never terminates either

Expected behavior

Subprocess code to be executed and to terminate immediately
This happens for all three Python versions if the entire code is executed directly

Steps to reproduce:

from multiprocessing import Process

def run():
    print("RUN")

p = Process(target=run)
p.start()
print("JOIN")
p.join(5.0)  # wait for 5 secs to let the process finish
print(p.is_alive())  # should be False
@int19h
Copy link
Contributor

int19h commented Nov 19, 2018

If you do this:

from multiprocessing import Process

def run():
    print("RUN")

if __name__ == "__main__":
    multiprocessing.set_start_method('spawn')  # note this line
    p = Process(target=run)
    p.start()
    print("JOIN")
    p.join(5.0)  # wait for 5 secs to let the process finish
    print(p.is_alive())  # should be False

Does it work for you on 3.6?

(Note that the __main__ thing is necessary in any case if your want your code to be portable to Windows.)

@sjdv1982
Copy link
Author

sjdv1982 commented Nov 19, 2018 via email

@int19h
Copy link
Contributor

int19h commented Nov 19, 2018

It disables fork altogether. When multiprocessing operates in this mode, no data is shared across processes at all, except what you pass as arguments to the function.

We don't support multiprocessing with fork currently - #943 tracks this feature, so I'll close this one as a dupe.

@int19h int19h closed this as completed Nov 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants