Skip to content
Open
13 changes: 11 additions & 2 deletions aiojobs/_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Optional,
Set,
Type,
TypedDict,
TypeVar,
Union,
)
Expand All @@ -24,9 +25,17 @@

Self = TypeVar("Self", bound="Scheduler")


class ExceptionHandlerDict(TypedDict, total=False):
message: str
job: Job
exception: Exception
source_traceback: TracebackType


_T = TypeVar("_T")
_FutureLike = Union["asyncio.Future[_T]", Awaitable[_T]]
ExceptionHandler = Callable[["Scheduler", Dict[str, Any]], None]
ExceptionHandler = Callable[["Scheduler", ExceptionHandlerDict], None]


class Scheduler(Collection[Job[object]]):
Expand Down Expand Up @@ -225,7 +234,7 @@ async def close(self) -> None:
self._failed_tasks.put_nowait(None)
await self._failed_task

def call_exception_handler(self, context: Dict[str, Any]) -> None:
def call_exception_handler(self, context: ExceptionHandlerDict) -> None:
if self._exception_handler is None:
asyncio.get_running_loop().call_exception_handler(context)
else:
Expand Down
Loading