Skip to content

Commit

Permalink
Fix typing issue in wait_for refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Dec 14, 2023
1 parent 737f5f8 commit 9bfe6b4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ert/scheduler/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 9bfe6b4

Please sign in to comment.