Fix CancelledError handling in done callbacks of cog init tasks (#6203)

This commit is contained in:
Jakub Kuczys 2023-07-19 22:45:44 +02:00 committed by GitHub
parent bad23a4a93
commit d8e584b5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -98,8 +98,13 @@ class Downloader(commands.Cog):
def create_init_task(self): def create_init_task(self):
def _done_callback(task: asyncio.Task) -> None: def _done_callback(task: asyncio.Task) -> None:
try:
exc = task.exception() exc = task.exception()
if exc is not None: except asyncio.CancelledError:
pass
else:
if exc is None:
return
log.error( log.error(
"An unexpected error occurred during Downloader's initialization.", "An unexpected error occurred during Downloader's initialization.",
exc_info=exc, exc_info=exc,

View File

@ -117,8 +117,13 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
def create_init_task(self) -> None: def create_init_task(self) -> None:
def _done_callback(task: asyncio.Task) -> None: def _done_callback(task: asyncio.Task) -> None:
try:
exc = task.exception() exc = task.exception()
if exc is not None: except asyncio.CancelledError:
pass
else:
if exc is None:
return
log.error( log.error(
"An unexpected error occurred during Mutes's initialization.", "An unexpected error occurred during Mutes's initialization.",
exc_info=exc, exc_info=exc,