Исправить обработку крупных результатов worker
This commit is contained in:
@@ -8,6 +8,7 @@ from uuid import UUID
|
||||
from ..config import load_settings
|
||||
from ..db import create_engine, create_session_factory
|
||||
from ..repositories import JobRepository
|
||||
from ..storage import S3Storage
|
||||
|
||||
|
||||
async def replay(job_id: UUID | None, attachment_id: UUID | None, dry_run: bool) -> int:
|
||||
@@ -21,6 +22,20 @@ async def replay(job_id: UUID | None, attachment_id: UUID | None, dry_run: bool)
|
||||
if job_id is None:
|
||||
print(f'REJECTED attachment_id={attachment_id} reason=job_not_found')
|
||||
return 2
|
||||
staging_key = await repository.failed_staging_key(job_id)
|
||||
if staging_key is None:
|
||||
print(f'REJECTED job_id={job_id} reason=not_failed_or_staging_missing')
|
||||
return 2
|
||||
storage = S3Storage(
|
||||
settings.s3_endpoint,
|
||||
settings.s3_access_key_id,
|
||||
settings.s3_secret_access_key,
|
||||
settings.s3_bucket,
|
||||
settings.s3_region,
|
||||
)
|
||||
if not await storage.exists(staging_key):
|
||||
print(f'REJECTED job_id={job_id} reason=staging_object_missing')
|
||||
return 2
|
||||
accepted = await repository.replay(job_id, datetime.now(timezone.utc), dry_run)
|
||||
if not accepted:
|
||||
print(f'REJECTED job_id={job_id} reason=not_failed_or_staging_missing')
|
||||
|
||||
Reference in New Issue
Block a user