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

Step over a thread join hangs debugger #1361

Closed
karthiknadig opened this issue Apr 16, 2019 · 0 comments · Fixed by #1360
Closed

Step over a thread join hangs debugger #1361

karthiknadig opened this issue Apr 16, 2019 · 0 comments · Fixed by #1360

Comments

@karthiknadig
Copy link
Member

@dpoole73 commented on Mon Apr 15 2019

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): 1029-3-6558
  • OS and version: MacOS version 10.14.4
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A (reproed with and without venv)
  • Relevant/affected Python packages and their versions: threading, time

Expected behaviour

F10 (step over) a join operation should move to the next statement or block while threads run

Actual behaviour

Step-over appears to hang the debugging until you break in and resume the thread showing "PAUSED ON PAUSE" status

Steps to reproduce:

I have attached a gif with the steps below plus showing that it doesn't repro when continuing rather than stepping over.
Untitled

  1. create a python file with the code below
import threading
import time

class RunThread(threading.Thread):
    kind = 'Thread'
    def __init__(self, name, fn, args = ()):
        threading.Thread.__init__(self)
        self.name = name
        self.fn   = fn
        self.args = args
        self.start()
    def run(self):
        self.fn(*(self.args))

def th1():
    while True:
        print('th1')
        time.sleep(1)

def th2():
    while True:
        print('th2')
        time.sleep(2)

def th3():
    while True:
        print('th3')
        time.sleep(4)

def main():
    threads = []
    threads.append(RunThread("aaa", th1))
    threads.append(RunThread("bbb", th2))
    threads.append(RunThread("ccc", th3))

    for t in threads:
        t.join()

if __name__ == '__main__':
    main()
  1. Set breakpoint on line 37
  2. Debug using the python current file default settings
  3. when the breakpoint is hit, hit F10 (or step over).
  4. after a few seconds break in by hitting pause, find the "PAUSED ON PAUSE" thread and continue it, execution will continue

The same thing doesn't happen if you continue rather than stepping over the join() call.

This impacts not only this scenario but seemingly anything that uses threads

Logs

Starting Microsoft Python language server.
[Info  - 3:42:41 PM] GetCurrentSearchPaths /usr/local/opt/python/bin/python3.7 
[Info  - 3:42:42 PM] Python search paths:
[Info  - 3:42:42 PM]     /private/var/folders/mm/2w6btf515j36vd2s3_2p6j740000gn/T/sr2eql2k.px2
[Info  - 3:42:42 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7
[Info  - 3:42:42 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
[Info  - 3:42:42 PM]     /Users/dpoole/Library/Python/3.7/lib/python/site-packages
[Info  - 3:42:42 PM]     /usr/local/lib/python3.7/site-packages
[Info  - 3:42:42 PM] Configuration search paths:
[Info  - 3:42:42 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python37.zip
[Info  - 3:42:42 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7
[Info  - 3:42:42 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
[Info  - 3:42:42 PM]     /Users/dpoole/Library/Python/3.7/lib/python/site-packages
[Info  - 3:42:42 PM]     /usr/local/lib/python3.7/site-packages
[Info  - 3:42:42 PM]     /usr/local/opt/python/bin
[Info  - 3:42:42 PM] Microsoft Python Language Server version 0.2.47.0
[Info  - 3:42:42 PM] Initializing for /usr/local/opt/python/bin/python3.7

Console

dpoole@dpoole-mac:/private/tmp/repro $ cd /private/tmp/repro ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /usr/local/opt/python/bin/python3.7 /Users/dpoole/.vscode/extensions/ms-python.python-2019.3.6558/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 54810 /private/tmp/repro/repro.py 
th3th2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant