Skip to content

Commit

Permalink
Merge pull request #8 from mild-blue/fix-shepherd-not-working-after-e…
Browse files Browse the repository at this point in the history
…rror

Fix shepherd not working after error during computation
  • Loading branch information
jakubmonhart authored Jan 31, 2024
2 parents 8a655c4 + 96f5c43 commit e36e605
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions shepherd/shepherd/shepherd.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ async def _report_job_failed(self, job_id: str, error: ErrorModel, sheep: BaseSh
status.error_details = error
status.finished_at = datetime.utcnow()

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

Expand Down Expand Up @@ -293,22 +294,22 @@ 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,
"exception_type": message.exception_type,
"exception_traceback": message.exception_traceback
})
await self._report_job_failed(job_id, error, sheep)
self._job_status.pop(job_id)
logging.info('Job `%s` from sheep `%s` failed (%s)', job_id, sheep_id, message.short_error)
logging.info('Job `%s` from sheep `%s` failed (%s)', job_id, sheep_id, message.message)

# notify about the finished job
sheep.in_progress.remove(job_id)

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 e36e605

Please sign in to comment.