fix: a long film's print file gets a render limit per 15 m part

Order #20 (23.6 m, 24 pieces) failed with "Falhou ao gerar": the whole
film had one 15 min limit, and two parts at 300 DPI take longer on the
server. The limit is now PRINT_RENDER_TIMEOUT_SECONDS (default 20 min)
for each part, and each claim records its deadline, so the stale-claim
check and the card's "Tempo limite" follow the same limit. A timeout, or
a final failed attempt, is logged as an error so Sentry sees it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-12 15:03:16 -03:00
parent c42e273c5b
commit a17287a118
4 changed files with 60 additions and 17 deletions

View File

@@ -173,8 +173,8 @@ def with_print_files(c, orders):
ids = [o['id'] for o in orders]
generated = c.execute('''SELECT p.order_id,p.item_index,p.status,p.upload_id,p.detail,p.claimed_at,p.finished_at,
p.created_at,
(p.status='rendering' AND p.claimed_at<now()-%s) AS timed_out,
p.claimed_at+%s AS timeout_at,u.name
(p.status='rendering' AND COALESCE(p.deadline_at,p.claimed_at+%s)<now()) AS timed_out,
COALESCE(p.deadline_at,p.claimed_at+%s) AS timeout_at,u.name
FROM dtf_local.print_files p LEFT JOIN dtf_local.uploads u ON u.id=p.upload_id
WHERE p.order_id=ANY(%s) ORDER BY p.item_index''', (CLAIM_TIMEOUT, CLAIM_TIMEOUT, ids)).fetchall()
upload_ids = sorted({str(uid) for order in orders for item in order['snapshot']['items']