Skip to content

Commit

Permalink
Notify about the finished job only once.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmonhart committed Jan 8, 2024
1 parent 63903ef commit 4877acf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions shepherd/shepherd/shepherd.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ async def _listen(self) -> None:
status.finished_at = datetime.utcnow()
await self._job_status_update_queue.enqueue_task(self._storage.set_job_status(job_id, status.copy()))
logging.info('Job `%s` from sheep `%s` done', job_id, sheep_id)

# notify about the finished job
async with self.job_done_condition:
self.job_done_condition.notify_all()

elif isinstance(message, ErrorMessage):
error = ErrorModel({
"message": message.message,
Expand All @@ -303,11 +308,7 @@ async def _listen(self) -> None:
logging.info('Job `%s` from sheep `%s` failed (%s)', job_id, sheep_id, message.message)

sheep.in_progress.remove(job_id)

# notify about the finished job
async with self.job_done_condition:
self.job_done_condition.notify_all()


def get_status(self) -> Generator[Tuple[str, SheepModel], None, None]:
"""
Get status information for all sheep
Expand Down

0 comments on commit 4877acf

Please sign in to comment.