diff --git a/src/ert/scheduler/job.py b/src/ert/scheduler/job.py index 4c860b11775..7bf6b3cf084 100644 --- a/src/ert/scheduler/job.py +++ b/src/ert/scheduler/job.py @@ -3,7 +3,7 @@ import asyncio import uuid from enum import Enum -from typing import TYPE_CHECKING, Callable, Optional +from typing import TYPE_CHECKING, Callable, Optional, TypeVar from cloudevents.conversion import to_json from cloudevents.http import CloudEvent @@ -18,6 +18,8 @@ from ert.ensemble_evaluator._builder._realization import Realization from ert.scheduler.scheduler import Scheduler +_T = TypeVar("_T") + class State(str, Enum): WAITING = "WAITING" @@ -86,7 +88,7 @@ async def __call__( await self._send(State.RUNNING) - async def threadsafer_future_wait(future: asyncio.Future): + async def threadsafer_future_wait(future: asyncio.Future[_T]) -> _T: while not future.done(): await asyncio.sleep(0.01) returncode = await future @@ -107,6 +109,7 @@ async def threadsafer_future_wait(future: asyncio.Future): "id": str(uuid.uuid1()), } ) + assert self._scheduler._events is not None await self._scheduler._events.put(to_json(timeout_event)) raise asyncio.CancelledError from None