mirror of
https://github.com/collinear-ai/yc-bench.git
synced 2026-04-19 12:58:03 +00:00
Fix task cancel: filter pending events by dedupe_key
SimEvent.payload is a generic SQLAlchemy JSON column, so .astext
(JSONB-only) raises AttributeError at runtime on every backend.
Filter on dedupe_key with the existing task:{tid}:* scheme, which
matches how core/eta.py queries the same events.
This commit is contained in:
parent
bfb0c88062
commit
3379ca0b7f
1 changed files with 3 additions and 2 deletions
|
|
@ -702,13 +702,14 @@ def task_cancel(
|
|||
# Set status to cancelled
|
||||
task.status = TaskStatus.CANCELLED
|
||||
|
||||
# Drop pending events for this task
|
||||
# Drop pending events for this task. Filter on dedupe_key (task:{tid}:*)
|
||||
# rather than payload — payload is generic JSON and `.astext` is JSONB-only.
|
||||
pending_events = (
|
||||
db.query(SimEvent)
|
||||
.filter(
|
||||
SimEvent.company_id == sim_state.company_id,
|
||||
SimEvent.consumed == False,
|
||||
SimEvent.payload["task_id"].astext == str(tid),
|
||||
SimEvent.dedupe_key.like(f"task:{tid}:%"),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue