You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting a breakpoint and attempting to drop into interactive mode whilst in an async view causes the server to crash, with the error:
RuntimeError: This event loop is already running
The screencast below demonstrates the issue described
2023-04-22.17-57-51.mp4
Traceback (most recent call last):
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/uvicorn-example/example.py", line 6, in app
await send(
^^^^
File "/home/jack/code/uvicorn-example/example.py", line 6, in app
await send(
^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/bdb.py", line 90, in trace_dispatch
return self.dispatch_line(frame)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/bdb.py", line 114, in dispatch_line
self.user_line(frame)
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 340, in user_line
self.interaction(frame, None)
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/core/debugger.py", line 335, in interaction
OldPdb.interaction(self, frame, traceback)
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 435, in interaction
self._cmdloop()
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 400, in _cmdloop
self.cmdloop()
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/debugger.py", line 140, in cmdloop
stop = self.onecmd(line)
^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 500, in onecmd
return cmd.Cmd.onecmd(self, line)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/cmd.py", line 217, in onecmd
return func(arg)
^^^^^^^^^
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/debugger.py", line 153, in do_interact
ipshell(
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/embed.py", line 245, in __call__
self.mainloop(
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/embed.py", line 337, in mainloop
self.interact()
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 873, in interact
code = self.prompt_for_code()
^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 812, in prompt_for_code
text = self.pt_app.prompt(
^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
return self.app.run(
^^^^^^^^^^^^^
File "/home/jack/code/uvicorn-example/.direnv/python-3.11.2/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 961, in run
return loop.run_until_complete(coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1511, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1504, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1377, in uvloop.loop.Loop.run_forever
File "uvloop/loop.pyx", line 518, in uvloop.loop.Loop._run
RuntimeError: this event loop is already running.
in flask the traceback is similar
Traceback (most recent call last):
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 2551, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 2531, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/asgiref/sync.py", line 240, in __call__
return call_result.result()
^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/asgiref/sync.py", line 306, in main_wrap
result = await self.awaitable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/app.py", line 9, in hello_world
return "<p>Hello, World!</p>"
^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/app.py", line 9, in hello_world
return "<p>Hello, World!</p>"
^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/bdb.py", line 90, in trace_dispatch
return self.dispatch_line(frame)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/bdb.py", line 114, in dispatch_line
self.user_line(frame)
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 340, in user_line
self.interaction(frame, None)
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/core/debugger.py", line 335, in interaction
OldPdb.interaction(self, frame, traceback)
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 435, in interaction
self._cmdloop()
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 400, in _cmdloop
self.cmdloop()
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/debugger.py", line 140, in cmdloop
stop = self.onecmd(line)
^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/pdb.py", line 500, in onecmd
return cmd.Cmd.onecmd(self, line)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/cmd.py", line 217, in onecmd
return func(arg)
^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/debugger.py", line 153, in do_interact
ipshell(
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/embed.py", line 245, in __call__
self.mainloop(
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/embed.py", line 337, in mainloop
self.interact()
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 873, in interact
code = self.prompt_for_code()
^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 812, in prompt_for_code
text = self.pt_app.prompt(
^^^^^^^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
return self.app.run(
^^^^^^^^^^^^^
File "/home/jack/code/flask-async/.direnv/python-3.11.2/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 961, in run
return loop.run_until_complete(coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_events.py", line 629, in run_until_complete
self._check_running()
File "/home/jack/.pyenv/versions/3.11.2/lib/python3.11/asyncio/base_events.py", line 588, in _check_running
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
The text was updated successfully, but these errors were encountered:
I'm not familiar enough with the stack to determine whether this is an issue with ipdb, or with the specific frameworks I'm using.
But I'm able to reproduce this using flask and uvicorn (and starlette/fastapi by association).
Taking the following flask code
Or the following uvicorn app
Setting a breakpoint and attempting to drop into interactive mode whilst in an async view causes the server to crash, with the error:
The screencast below demonstrates the issue described
2023-04-22.17-57-51.mp4
in flask the traceback is similar
The text was updated successfully, but these errors were encountered: