2

I running 2 thread in python and execute the function Do().

import sys, threading

def do():
    print ("Execute")

def run():
    def start_thread():
        thread = threading.Thread(target = do)
        thread.start()
        thread.join()
        return thread

    t1 = start_thread()
    t2 = start_thread()

run()
print('Press enter to Quit')
sys.stdin.readline()

After running the run() function, the threads t1 and t2 are out of scope. But, according to VS-Code, they are still in Running mode.

enter image description here

I wait for them to join(). This mean that they are terminated. So, how they are still running? How to release those threads safely?

5
  • 5
    Couldn't replicate this situation outside of VSCode, my guess is that it's a problem in the editor, not in Python runtime. Your code actually cannot have 2 concurrent running threads, since you join the first thread before starting second thread. Commented Mar 21, 2018 at 15:16
  • With which IDE you tested it? Someone can confirm that this is bug in VS-Code? Commented Mar 22, 2018 at 7:45
  • I ran it in terminal, with htop running in second terminal with filter on python turned on (you can turn it on with F4). As soon as threads joined, they disappeared from htop. I am on Linux. Commented Mar 22, 2018 at 8:57
  • Feel free to report a bug at github.com/Microsoft/vscode-python/issues Commented Mar 22, 2018 at 23:04
  • I just reported on this. URL = github.com/Microsoft/vscode-python/issues/1191 Commented Mar 25, 2018 at 13:24

1 Answer 1

1
  • Go into launch.json (Ctrl+Shift+P and type the filename)
  • Change the setting of your launch option from "type":"python" to "type":"pythonExperimental"

It seems to be a bug in vscode. The solution was post in response to the issue that you reported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.