Skip to content

Commit

Permalink
Use asyncio.Lock for forward_model_ok
Browse files Browse the repository at this point in the history
This makes sure that we will not run more than 1 internalization job at a time.
  • Loading branch information
xjules committed Aug 26, 2024
1 parent 802c897 commit 4bbfd5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ert/scheduler/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ async def run(self, sem: asyncio.BoundedSemaphore, max_submit: int = 1) -> None:
if self.returncode.result() == 0:
if self._scheduler._manifest_queue is not None:
await self._verify_checksum()
await self._handle_finished_forward_model()
async with self._scheduler._forward_model_ok_lock:
await self._handle_finished_forward_model()
break

if attempt < max_submit - 1:
Expand Down
4 changes: 4 additions & 0 deletions src/ert/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def __init__(
self._completed_jobs_num: int = 0
self.completed_jobs: asyncio.Queue[int] = asyncio.Queue()

# this lock is to assure that no more than 1 task
# does internalization at a time
self._forward_model_ok_lock: asyncio.Lock = asyncio.Lock()

self._cancelled = False
if max_submit < 0:
raise ValueError(
Expand Down

0 comments on commit 4bbfd5c

Please sign in to comment.