Skip to content

Commit

Permalink
Remove start sync event from scheduler job.__call__
Browse files Browse the repository at this point in the history
The scheduler job has a synchronization event (`start = asyncio.Event()`) with the purpose of executing job-group start,  and was passed as a parameter to `job.__call__`. It does not seems to be that necessary in the end as `asyncio.BoundedSemaphore` will handle job execution regardless. This commit removes this redundant event.
  • Loading branch information
jonathan-eq committed Apr 10, 2024
1 parent d55e0ef commit c600efb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/ert/scheduler/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ async def _submit_and_run_once(self, sem: asyncio.BoundedSemaphore) -> None:
timeout_task.cancel()
sem.release()

async def run(
self, start: asyncio.Event, sem: asyncio.BoundedSemaphore, max_submit: int = 2
) -> None:
async def run(self, sem: asyncio.BoundedSemaphore, max_submit: int = 2) -> None:
self._requested_max_submit = max_submit
await start.wait()
for attempt in range(max_submit):
await self._submit_and_run_once(sem)

Expand Down
5 changes: 1 addition & 4 deletions src/ert/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,12 @@ async def execute(
)
scheduling_tasks.append(asyncio.create_task(self._update_avg_job_runtime()))

start = asyncio.Event()
sem = asyncio.BoundedSemaphore(self._max_running or len(self._jobs))
for iens, job in self._jobs.items():
self._job_tasks[iens] = asyncio.create_task(
job.run(start, sem, self._max_submit), name=f"job-{iens}_task"
job.run(sem, self._max_submit), name=f"job-{iens}_task"
)

start.set()

try:
await self._monitor_and_handle_tasks(scheduling_tasks)
finally:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/scheduler/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def test_job_run_sends_expected_events(
job.started.set()

job_run_task = asyncio.create_task(
job.run(job.started, asyncio.Semaphore(), max_submit=max_submit)
job.run(asyncio.Semaphore(), max_submit=max_submit)
)

for attempt in range(max_submit):
Expand Down

0 comments on commit c600efb

Please sign in to comment.