ipdb
ipdb copied to clipboard
aiohttp docker breaks with bad file descriptor and assertion error
I'm running a docker aiohttp service with the following:
python==3.6.5 aiohttp==3.5.3 ipython==7.2.0 ipdb==0.11
After adding
import ipdb; ipdb.set_trace()
to a subclass of aiohttp.web.View, then running with docker-compose run --rm --service-ports aiohttp I get the following error output:
89 import ipdb; ipdb.set_trace()
---> 90 requests = await self.request.json()
91 logger.debug(f'Making [{len(requests)}] service calls at [{datetime.now()}]')
Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 652, in _run_async2
result = yield f
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
new_f = coroutine.send(None)
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 591, in _run_async
with self.input.raw_mode():
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/input/vt100.py", line 231, in __enter__
os.write(self.fileno, b'\x1b[?1l')
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.6/site-packages/aiohttp/web_urldispatcher.py", line 890, in _iter
resp = await method()
File "/orm/service/api/views.py", line 90, in post
requests = await self.request.json()
File "/orm/service/api/views.py", line 90, in post
requests = await self.request.json()
File "/usr/local/lib/python3.6/bdb.py", line 51, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/local/lib/python3.6/bdb.py", line 69, in dispatch_line
self.user_line(frame)
File "/usr/local/lib/python3.6/pdb.py", line 261, in user_line
self.interaction(frame, None)
File "/usr/local/lib/python3.6/site-packages/IPython/core/debugger.py", line 297, in interaction
OldPdb.interaction(self, frame, traceback)
File "/usr/local/lib/python3.6/site-packages/pdb.py", line 227, in interaction
getattr(self, '_cmdloop', self.cmdloop)()
File "/usr/local/lib/python3.6/pdb.py", line 321, in _cmdloop
self.cmdloop()
File "/usr/local/lib/python3.6/site-packages/IPython/terminal/debugger.py", line 88, in cmdloop
line = self.pt_app.prompt() # reset_current_buffer=True)
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py", line 733, in prompt
return run_sync()
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py", line 722, in run_sync
return self.app.run(inputhook=self.inputhook, pre_run=pre_run2)
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 699, in run
return run()
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 673, in run
return f.result()
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/eventloop/future.py", line 149, in result
raise self._exception
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 90, in step_next
new_f = coroutine.throw(exc)
File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 654, in _run_async2
assert not self._is_running
AssertionError
I don't get this error when using the same versions of python, ipython, ipdb in a dockerized django project. It only occurs with dockerized asyncio/aiohttp.
Note that changing to import pdb; pdb.set_trace() starts the pdb debugger without a problem.