Explorer
/proc/117/root/tmp/p23_requeue_test.py
← Zurück ↓ Download
import sqlite3, json
DB = '/opt/struktur/youtube-research/knowledge.db'
ids = [183, 182, 181, 180, 179, 12, 13, 14, 15, 16]
c = sqlite3.connect(DB, timeout=15, isolation_level=None)
c.row_factory = sqlite3.Row
c.execute('PRAGMA busy_timeout=10000')
c.execute('BEGIN IMMEDIATE')
rows = c.execute(
    'SELECT job_id,status,attempts FROM e2e_jobs WHERE job_id IN (%s)' % ','.join('?' * len(ids)), ids
).fetchall()
assert len(rows) == 10 and all(r['status'] == 'blocked_transcript_fetch' for r in rows), rows
for jid in ids:
    c.execute(
        "UPDATE e2e_jobs SET status='queued',step='queued',reserved_at=NULL,completed_at=NULL,lease_until=NULL,error_code=NULL,error_message=NULL,updated_at=CURRENT_TIMESTAMP WHERE job_id=? AND status='blocked_transcript_fetch'",
        (jid,)
    )
assert c.total_changes == 10, c.total_changes
c.execute('COMMIT')
check = c.execute(
    'SELECT job_id,youtube_id,status,step,attempts,reserved_at,completed_at,lease_until,error_code FROM e2e_jobs WHERE job_id IN (%s) ORDER BY job_id' % ','.join('?' * len(ids)), ids
).fetchall()
print(json.dumps([dict(r) for r in check], ensure_ascii=False))
c.close()