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

Python debugger does not halt on exceptions in async coroutines #1309

Closed
andersea opened this issue Apr 5, 2018 · 2 comments
Closed

Python debugger does not halt on exceptions in async coroutines #1309

andersea opened this issue Apr 5, 2018 · 2 comments
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug

Comments

@andersea
Copy link

andersea commented Apr 5, 2018

Environment data

  • VS Code version: 1.21.1
  • Extension version (available under the Extensions sidebar): 2018.3.1
  • OS and version: Kubuntu 17.10 Kernel 4.13.0-38-generic 64bit
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: All

Actual behavior

When debugging async/await code, if an exception is thrown, the debugger halts at the loop entry point instead of where the exception happened.

Expected behavior

The debugger should stop where the exception happens.

Steps to reproduce:

Run this code in the debugger:

import asyncio

def error():
    raise Exception('Something bad happened')

async def main():
    print('Hello world.')
    await asyncio.sleep(1)
    # Expectation: Debugger should stop here
    error()
    await asyncio.sleep(1)
    print('Bye.')

loop = asyncio.get_event_loop()
# Actual: Debugger stops here.
loop.run_until_complete(main())

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Linter 'pylint' is not installed. Please install it or select another linter".
Error: Module 'pylint' not installed.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

~/python/async_exception_debugging$ cd /home/username/python/async_exception_debugging ; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1" /home/username/python/async_exception_debugging/env/bin/python /home/username/.vscode/extensions/ms-python.python-2018.3.1/pythonFiles/PythonTools/visualstudio_py_launcher.py /home/username/python/async_exception_debugging 40845 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput /home/username/python/async_exception_debugging/app.py
Hello world.
Traceback (most recent call last):
  File "/home/username/python/async_exception_debugging/app.py", line 16, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/home/username/python/async_exception_debugging/app.py", line 10, in main
    error()
  File "/home/username/python/async_exception_debugging/app.py", line 4, in error
    raise Exception('Something bad happened')
Exception: Something bad happened
@andersea
Copy link
Author

andersea commented Apr 5, 2018

It seems to work correctly in the experimental debugger.

@DonJayamanne
Copy link

@andersea

Thank you very much for getting back on this.

I'm closing this issue as this works with the experimental debugger (soon to be made the default debugger).

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug area-debugging labels Apr 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants