Skip to content

Commit 3b657eb

Browse files
TizzySaurusChrisLovering
authored andcommitted
Handle 90001 forbidden errors by default in schedules
1 parent 3d11528 commit 3b657eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pydis_core/utils/scheduling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def schedule(self, task_id: abc.Hashable, coroutine: abc.Coroutine) -> None:
8080
coroutine.close()
8181
return
8282

83-
task = asyncio.create_task(coroutine, name=f"{self.name}_{task_id}")
83+
task = asyncio.create_task(_coro_wrapper(coroutine), name=f"{self.name}_{task_id}")
8484
task.add_done_callback(partial(self._task_done_callback, task_id))
8585

8686
self._scheduled_tasks[task_id] = task
@@ -252,6 +252,7 @@ def create_task(
252252

253253

254254
async def _coro_wrapper(coro: abc.Coroutine[typing.Any, typing.Any, TASK_RETURN]) -> None:
255+
"""Wraps `coro` in a try/except block that will handle 90001 Forbidden errors."""
255256
try:
256257
await coro
257258
except Forbidden as e:

0 commit comments

Comments
 (0)