aiopg: connection.cancel can hang

we noticed this callstack in our prod server which hung our main thread breaking the server:

Jul 30 16:48:45.114            File "/usr/local/lib/python3.6/asyncio/base_events.py", line 422 in run_forever
Jul 30 16:48:45.114            File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1434 in _run_once
Jul 30 16:48:45.114            File "/usr/local/lib/python3.6/asyncio/events.py", line 145 in _run
Jul 30 16:48:45.114            File "/usr/local/lib/python3.6/site-packages/aiopg/connection.py", line 226 in cancel

suggest loop.run_in_executor’ing it as supposedly this method is thread safe. Ideally there would be a timeout that affects this as well. I’m not sure if the DSN connect_timeout applies

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 30 (29 by maintainers)

Most upvoted comments

Still creates an issue for some of us. I guess there isn’t much to do?

@asvetlov @vir-mir do you intend on returning to this at any point? It’s been over a year since I opened the PR…

probably should call cancel from a executor

I’m in favor. Happy to modify my PR accordingly