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

Debugger does not break when calling back from C created thread #2137

Closed
ido-ran opened this issue Sep 25, 2020 · 3 comments
Closed

Debugger does not break when calling back from C created thread #2137

ido-ran opened this issue Sep 25, 2020 · 3 comments

Comments

@ido-ran
Copy link

ido-ran commented Sep 25, 2020

I have first open this bug in microsoft/vscode-python#14098 - but maybe here it's more appropriate.

Environment data

  • Version: 1.49.0 (system setup)
  • Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
  • Date: 2020-09-10T13:22:08.892Z
  • Electron: 9.2.1
  • Chrome: 83.0.4103.122
  • Node.js: 12.14.1
  • V8: 8.3.110.13-electron.0
  • OS: Windows_NT x64 10.0.19041
  • Extension version (available under the Extensions sidebar): v2020.8.109390
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: none
  • Relevant/affected Python-related VS Code extensions and their versions: none
  • Value of the python.languageServer setting: Jedi

Expected behaviour

The debugger will break on the breakpoint set in VS Code.

Actual behaviour

The debugger does not break on the breakpoint set.

Steps to reproduce:

  1. Clone https://github.com/ido-ran/vscode-python-cthread-debugging
  2. Run create-venv.sh once to create venv
  3. Run build_thrd.sh to build Cyton extension
  4. Open test_threading.py in VS Code
  5. Add breakpoint on the print statement in handler function
  6. Start debug by pressing F5 or open the Run tab and click Start Debugging
@fabioz
Copy link
Contributor

fabioz commented Sep 25, 2020

This is a known issue...

We already tried some approaches and still haven't been able to come up with a good solution to do that in the general case, so, for now, you're required to manually ask for non-python started threads to be traced.

To do that you can use the following api:

import debugpy
debugpy.debug_this_thread()

@ido-ran
Copy link
Author

ido-ran commented Sep 25, 2020

Thanks @fabioz. I've added this call into my pyx file and that is solving the problem in VS Code.
I actually need to make it work in PyCharm as well, using this snippet seems to cover all bases as both PyCharm and VS Code are using pydev under the hood:

    try:
        import pydevd
        pydevd.settrace(suspend=False)
    except:
        # ignore if debugger is not available
        pass

@fabioz
Copy link
Contributor

fabioz commented Sep 25, 2020

Yeap, using the pydevd api directly should also work for debugpy ;)

p.s.: I'm closing as this is a known issue which is being tracked elsewhere.

@fabioz fabioz closed this as completed Sep 25, 2020
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