From 7225fa7245282ad5954afbc57bf474a16838b7da Mon Sep 17 00:00:00 2001 From: Patrick Gingras <775.pg.12@gmail.com> Date: Fri, 30 Oct 2020 22:22:33 -0400 Subject: [PATCH] catch asyncio.CancelledError as well as concurrent.futures.CancelledError as of [bpo-32528](https://bugs.python.org/issue32528), asyncio.CancelledError is not a subclass of concurrent.futures.CancelledError. This means that if an asyncio future raises an exception, it won't be caught. Therefore, the exception will bubble past the try-except within the loop in application_checker, resulting in done applications not being cleaned up, and the application_checker task not being queued again. --- daphne/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daphne/server.py b/daphne/server.py index f367e06..77bd2d1 100755 --- a/daphne/server.py +++ b/daphne/server.py @@ -277,7 +277,7 @@ class Server(object): if application_instance and application_instance.done(): try: exception = application_instance.exception() - except CancelledError: + except (CancelledError, asyncio.CancelledError): # Future cancellation. We can ignore this. pass else: