-
Notifications
You must be signed in to change notification settings - Fork 147
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
Trouble with asyncio and ipdb #184
Comments
|
I came across this problem multiple times in different projects. In many situations project authors recommends to avoid using def threaded(func):
def wrapper(*args, **kwargs):
result = []
def target():
result.append(func(*args, **kwargs))
thread = threading.Thread(target=target)
thread.start()
thread.join()
return result[0]
return wrapper
from IPython.terminal.debugger import TerminalPdb
TerminalPdb.cmdloop = threaded(TerminalPdb.cmdloop) Probably the problem can be fixed somewhere inside |
@apatrushev Thanks for documenting your workaround. |
I started to experience this issue when I upgraded my ipython from 7.9.0 to 7.12.0 (looks like the change occured in 7.10.0: ipython/ipython@c2a5384) in which ipython started to support prompt_toolkit 3.0. I opened an issue in prompt_toolkit (prompt-toolkit/python-prompt-toolkit#1084) to see if they have any suggestions, but very possibly ipython (or even ipdb) needs to find a workaround, because it looks the prompt_toolkit app was not designed to be run from inside an event loop. A temporary workaround which worked for me is to pin my prompt_toolkit to 2.0.10. |
Fixed in ipython: ipython/ipython#12141 |
@om-saran When new IPython is released, can you confirm and close ? |
@brianmaissy I have doubts whether this was the right way to go. Turns out that this makes IPDB hang up if
Previously, this would show the following tb:
Now it just hangs without responding to |
@MrMino I'm not familiar with the code enough to feel confident trying to address this. Maybe the best way to address it is to open a separate issue? Also maybe @jonathanslenders has some insight? |
@brianmaissy I tried to fix this in different ways for the last few hours and I now believe that it comes down to a fundamental limitation with asyncio: switching / recursive event loops are not possible. In this context having a debugger run an event loop in a separate thread seems like the most sane thing to do. We'd just need to check if the file descriptor for stdout is something usable. |
I've been struggling with this one for a couple of days. I've tried a bunch of (ipdb, ipython, prompt-toolkit) version combinations and the one that's working the best for me is: ipdb==0.10.0 This only gives me
as opposed to one of the following
When I call "self" for example when debugging with ipdb, I'll get a different result on the next call, and the first one again on the third call, I guess because of the asynchronous nature of the application/framework (Odoo) I'm developing in. IIRC this did not happen with ipython versions >= 5. |
I'm finding trouble using ipdb in this scenario.
Not sure if I'm missing something here
The error thrown:
$ python ipd.py
OS: MacOS 10.13.6
Python version: 3.8.1
ipython version: 7.11.1
ipdb version: 0.12.3
The same works fine with pdb
The text was updated successfully, but these errors were encountered: