▲ | rich_sasha 2 days ago | |
Cancellations probably caused more bugs in my async code than anything else. If any code in your coroutine, including library code, has a broad try/except, there's good chances that eventually the cancellation exception will be swallowed up and ignored. Catch-all try/except of course isn't the pinnacle of good software engineering, but it happens a lot, in particular in server-tyoe applications. You may have some kind of handler loop that handles events periodically, and if one such handling fails, with an unknowabl exception, you want to log it and continue. So then you have to remember to explicitly reraise cancellation errors. Maybe it's the least bad Pythonic option, but it's quite clunky for sure. |