How to use pdb inside an app running with adev?
amirouche opened this issue · comments
I am using adev in my aiohttp application. I've setup a pdb
inside the app, when I get the following error:
Traceback (most recent call last):
File "/home/amirouche/.virtualenvs/socialite/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 417, in start
resp = yield from self._request_handler(request)
File "/home/amirouche/.virtualenvs/socialite/lib/python3.5/site-packages/aiohttp/web.py", line 289, in _handle
resp = yield from handler(request)
File "/home/amirouche/.virtualenvs/socialite/lib/python3.5/site-packages/aiohttp_devtools/runserver/serve.py", line 62, in _handler
return await handler(request)
File "/home/amirouche/src/python/socialite/socialite/api.py", line 34, in status
try:
File "/home/amirouche/src/python/socialite/socialite/api.py", line 34, in status
try:
File "/usr/lib/python3.5/bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/lib/python3.5/bdb.py", line 67, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
Is it possible to use both adev and pdb (or better aiomonitor)
I can reproduce the error, for the record
from aiohttp import web
async def handle(request):
import pdb
pdb.set_trace()
return web.Response(text='hello')
app = web.Application()
app.router.add_get('/', handle)
if __name__ == '__main__':
web.run_app(app, port=8000)
Gives the error when called with adev runserver error.py
but works fine with run directly python error.py
.
My guess would be that the problem is related to watchdog (used to watch for file changes) which makes use of threads. I think threads don't play nicely with pdb?
I have some ambition to build an asyncio interface to watch for file changes which would probably fix this, but that's probably too far away.
In the mean time, I'm not sure what to suggest. I'll have a proper play and see if I can sort the problem when I get a chance.
In the mean time, I'm not sure what to suggest. I'll have a proper play and see if I can sort the problem when I get a chance.
I don't need that feature myself, but I know people will find it handy. Ping me you need help.