Skip to content

Commit

Permalink
fixup: switch type to BaseException for python 3.8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Jul 2, 2023
1 parent ee27c72 commit 39ed81c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ async def handle_connection_init_timeout(self) -> None:
self.connection_timed_out = True
reason = "Connection initialisation timeout"
await self.close(code=4408, reason=reason)
except Exception as error:
except BaseException as error:
# for python 3.8 compatibility use BaseException
# asyncio.CancelledError didn't inherit from Exception in python < 3.9
await self.handle_task_exception(error) # pragma: no cover
finally:
# do not clear self.connection_init_timeout_task
# so that unittests can inspect it.
self.completed_tasks.append(task)

async def handle_task_exception(self, error: Exception) -> None:
async def handle_task_exception(self, error: BaseException) -> None:
# for python 3.8 compatibility use BaseException
# asyncio.CancelledError didn't inherit from Exception in python < 3.9
if isinstance(error, asyncio.CancelledError):
self.task_logger.exception("Worker task cancelled", exc_info=error)
else:
Expand Down

0 comments on commit 39ed81c

Please sign in to comment.