Fix cold worker claim result mapping with Core updates

This commit is contained in:
Artyom
2026-11-06 10:35:08 +03:00
parent 1212c562d2
commit 2e428cf8e6
4 changed files with 70 additions and 8 deletions
@@ -39,9 +39,6 @@ async def handle_job(
job_id=str(job.id),
error=type(error).__name__,
error_code=getattr(getattr(error, "orig", error), "sqlstate", None),
reason=type(
getattr(getattr(getattr(error, "orig", None), "__cause__", None), "__cause__", None)
).__name__,
)
await asyncio.sleep(REQUEUE_DELAY_SECONDS)
await message.nack(requeue=True)
@@ -2,7 +2,7 @@ import json
from collections.abc import AsyncIterator, Sequence
from contextlib import asynccontextmanager
from datetime import datetime, timedelta
from typing import Any
from typing import Any, cast
from uuid import UUID
from sqlalchemy import (
@@ -16,6 +16,7 @@ from sqlalchemy import (
Integer,
RowMapping,
Select,
Table,
Text,
UniqueConstraint,
delete,
@@ -498,7 +499,7 @@ class PostgresJobRepository:
)
def _owned(self, lease: Lease):
return update(JobRow).where(
return update(cast(Table, JobRow.__table__)).where(
JobRow.job_id == lease.job.id,
JobRow.status == "processing",
JobRow.lease_token == lease.token,
@@ -535,7 +536,7 @@ class PostgresJobRepository:
async def claim(self, job: Job, token: UUID, lease: timedelta) -> Claim | None:
row = (
await self._session.execute(
update(JobRow)
update(cast(Table, JobRow.__table__))
.where(
JobRow.job_id == job.id,
JobRow.attachment_id == job.attachment_id,
@@ -634,7 +635,7 @@ class PostgresJobRepository:
outcome = Outcome.SUPERSEDED if published is None else Outcome.DONE
if outcome is Outcome.SUPERSEDED:
await self._session.execute(
update(JobRow)
update(cast(Table, JobRow.__table__))
.where(JobRow.job_id == job.id)
.values(status="superseded", updated_at=func.now())
)
@@ -761,7 +762,7 @@ class PostgresJobRepository:
)
row = (
await self._session.execute(
update(JobRow)
update(cast(Table, JobRow.__table__))
.where(JobRow.job_id == job_id)
.values(
status="queued",