Skip to content

Commit

Permalink
Fixed job result getting prematurely deleted in fringe cases
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Jul 26, 2024
1 parent 5795f1f commit 7168478
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/apscheduler/datastores/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,13 +1047,12 @@ async def get_job_result(self, job_id: UUID) -> JobResult | None:
query = self._t_job_results.select().where(
self._t_job_results.c.job_id == job_id
)
row = (await self._execute(conn, query)).first()

# Delete the result
delete = self._t_job_results.delete().where(
self._t_job_results.c.job_id == job_id
)
await self._execute(conn, delete)
if row := (await self._execute(conn, query)).one_or_none():
# Delete the result
delete = self._t_job_results.delete().where(
self._t_job_results.c.job_id == job_id
)
result = await self._execute(conn, delete)

return JobResult.unmarshal(self.serializer, row._asdict()) if row else None

Expand Down

0 comments on commit 7168478

Please sign in to comment.