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.

Ipdb and Flask No longer work together

See original GitHub issue

I wanted to mention this here. I can’t be the only that uses flask and ipdb together. Using “import ipdb;ipdb.set_trace()” has worked well in flask apps for the longest time up until a recent update. I tracked it down to ipython. v7.9.0 works but v7.10.0 does not. 😦

Just wanted someone to be aware. Is it possible to get an explanation of what might have caused this? Wondering if there might be a workaround possibly? For now, downgrading to v7.9.0 works for now. Just would be nice to know if I have to look for another solution in the future.

It now gives this error when hitting the breakpoint:

File "/.venv/lib/python3.7/site-packages/IPython/terminal/debugger.py", line 97, in cmdloop
    line = self.pt_app.prompt() # reset_current_buffer=True)
  File "/.venv/lib/python3.7/site-packages/prompt_toolkit/shortcuts/prompt.py", line 986, in prompt
    return self.app.run()
  File "/.venv/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/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-3'.

Reproducing this error can be done with the simplest flask app:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    import ipdb;ipdb.set_trace()
    return 'Hello, World!'

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
shifrcommented, Dec 11, 2019

Same here with 7.10.1. Rollback to 7.9.0 helps

2reactions
rishikant42commented, Dec 6, 2019

@jchang10 I don’t think this issue is specific to flask framework. I have faced the same issue in Django as well. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When added ipdb at flask app it raises RuntimeError
Okay now I'm working on simple flask app and it is working but while working I needed ipdb at certain api, after I...
Read more >
ipdb · PyPI
ipdb exports functions to access the IPython debugger, which features tab completion, syntax highlighting, better tracebacks, better introspection with the same ...
Read more >
Setting Up Sublime Text 3 for Full Stack Python Development
This article details how to set up Sublime Text for full stack Python development.
Read more >
Debugging configurations for Python apps in Visual Studio Code
Note: Starting a debugging session through the Debug Panel, F5 or Run > Start Debugging when no configuration exists will also bring up...
Read more >
Make the most of Python Jupyter notebooks - Little Umbrellas
You can read more about the magic function system by calling the ... And this is how you clear no longer needed variables...
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