alper
alper

Reputation: 3390

How can I use breakpoint inside a Hypercorn funtion for Python 3.9

I am using Python 3.9. I am unable to use ipdb.set_trace() inside an Hypercorn process. Please note that this works in Python 3.7.

My code:

#!/usr/bin/env python3

import ipdb

async def app(scope, receive, send):
    ipdb.set_trace()  # DEBUG

When I run (hypercorn hello_world:app) I get following error message:

❯ hypercorn hello_world:app
--Return--
None
> /home/alper/trade_bot/bot/hello_world.py(7)app()
      5
      6 async def app(scope, receive, send):
----> 7     ipdb.set_trace()  # DEBUG

ipdb>
[2024-11-25 16:07:33 +0000] [1228742] [WARNING] ASGI Framework Lifespan error, continuing without Lifespan support
[2024-11-25 16:07:33 +0000] [1228742] [INFO] Running on http://127.0.0.1:8000 (CTRL + C to quit)
--Return--
None
> /home/alper/trade_bot/bot/hello_world.py(7)app()
      5
      6 async def app(scope, receive, send):
----> 7     ipdb.set_trace()  # DEBUG

ipdb>
[2024-11-25 16:07:35 +0000] [1228742] [ERROR] Error in ASGI Framework
Traceback (most recent call last):
  File "/home/alper/venv/lib/python3.9/site-packages/hypercorn/asyncio/task_group.py", line 27, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/home/alper/venv/lib/python3.9/site-packages/hypercorn/app_wrappers.py", line 34, in __call__
    await self.app(scope, receive, send)
  File "/home/alper/trade_bot/bot/hello_world.py", line 7, in app
    ipdb.set_trace()  # DEBUG
  File "/usr/lib/python3.9/bdb.py", line 92, in trace_dispatch
    return self.dispatch_return(frame, arg)
  File "/usr/lib/python3.9/bdb.py", line 154, in dispatch_return
    if self.quitting: raise BdbQuit
bdb.BdbQuit

Here ipdb> does not accept any input like c, n... How can I do debugging using breakpoint (ipdb.set_trace()) inside a Hypercorn process, if possible?

Upvotes: 1

Views: 26

Answers (0)

Related Questions