question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite loop when using ipdb on ipython 7.13+

See original GitHub issue

I use pytest with appium and when I use ipdb.set_trace() I’m stuck in a loop:

Exception in thread Thread-21249:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/vverdeil/workspace/venv/testenv/lib/python3.7/site-packages/IPython/terminal/debugger.py", line 102, in in_thread
    line = self.pt_app.prompt()
  File "/Users/vverdeil/workspace/venv/testenv/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 986, in prompt
    return self.app.run()
  File "/Users/vverdeil/workspace/venv/testenv/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 788, in run
    return get_event_loop().run_until_complete(self.run_async(pre_run=pre_run))
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 644, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-21249'.

As you can see I reached thread 21249 before managing to kill the process.

With the same code it works as expected on ipython 7.12, so I guess is it linked to https://github.com/ipython/ipython/pull/12141/

Am I the only one having this bug?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

1reaction
delijaticommented, Jan 14, 2021

Yeah i still into the same issue. Welcome back to pre ipdb times 😭

ipdb> request
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/IPython/terminal/debugger.py", line 122, in in_thread
    line = self.pt_app.prompt()
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1013, in prompt
    return self.app.run(set_exception_handler=set_exception_handler)
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 816, in run
    return loop.run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 783, in run_async
    return await _run_async2()
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 771, in _run_async2
    await self.cancel_and_wait_for_background_tasks()
  File "/home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 872, in cancel_and_wait_for_background_tasks
    await task
RuntimeError: Task <Task pending name='Task-7' coro=<Application.run_async() running at /home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/application/application.py:783> cb=[_run_until_complete_cb() at /usr/lib/python3.8/asyncio/base_events.py:184]> got Future <Task pending name='Task-52' coro=<KeyProcessor._start_timeout.<locals>.wait() running at /home/ubuntu/html/env/lib/python3.8/site-packages/prompt_toolkit/key_binding/key_processor.py:406> wait_for=<Future cancelled>> attached to a different loop

versions:

prompt-toolkit==3.0.10
ipdb==0.13.4
ipython==7.19.0

In the meantime pdbpp works.

1reaction
werdeilcommented, Nov 17, 2020

While trying to provide a simple script to reproduce I found out a fix: I had the the issue in an environment with prompt-toolkit==3.0.2 and it is resolve by prompt-toolkit==3.0.8.

Read more comments on GitHub >

github_iconTop Results From Across the Web

7.x Series — IPython 7.31.0 documentation
This should fix some issues/infinite loop, but let us know if you come across any regressions. In particular this fixes issues with kmaork/madbg, ......
Read more >
Stuck in Ipython debugger loop [duplicate] - Stack Overflow
The main way I use to exit the loop is Ctrl + Z . Otherwise, it is also possible to execute: ipdb> import...
Read more >
IPython Documentation
loops with Python's PyOS_InputHook API. A new command-line flag –gui controls GUI support, and it can also be enabled after IPython startup ...
Read more >
Python Notes for Professionals
Section 7.1: Creating an enum (Python 2.4 through 3.3) ... Section 21.5: List Comprehensions with Nested Loops ... Section 103.1: Via IPython and...
Read more >
Jupyter Lesson 9: How to Interrupt the Kernel (Stop code from ...
Every now and then you will run code that either runs forever (infinite loop) or has errors you identified and want to stop....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found