Commits
Click on a commit to change the comparison rangeAdd task keys to docket calls in API handlers to prevent duplicate execution
When multiple API servers process the same request, docket tasks could be
created and executed in parallel, causing database contention and potential
deadlocks. This adds unique task keys to all docket.add() calls in API
handlers so that only one task with a given key can be scheduled at a time.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>7 hours ago
by desertaxle Merge branch 'main' into add-docket-task-keys6 hours ago
by desertaxle Add tests for docket task keys in API handlers
Tests verify that API handlers use deterministic task keys when scheduling
background docket tasks. The tests confirm:
- Keys are based on relevant resource IDs (work queue, work pool, deployment, etc.)
- Same request parameters produce identical keys (at-most-once semantics)
- Deployment IDs are sorted to ensure order-independent keys
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>6 hours ago
by desertaxle Add integration tests for at-most-once execution with real Docket
These tests verify the actual at-most-once execution behavior by using a real
Docket instance and inspecting the task queue via docket.snapshot(). The tests
confirm that:
- Duplicate API requests only queue one task per unique key
- Task keys are properly formed and present in the Docket queue
- Deployment ID ordering doesn't affect task key generation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>2 hours ago
by desertaxle Remove mock-based tests, keep only real Docket integration tests
The integration tests using a real Docket instance are more valuable as they
verify the actual at-most-once execution behavior by inspecting the task queue.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>2 hours ago
by desertaxle Fix ContextVar issue in test fixtures for Python 3.10
Use the existing `app` fixture (which handles temporary_settings properly)
and only add the lifespan context in the async generator fixture. This
avoids the ContextVar token error that occurs when temporary_settings
context manager is entered/exited in different async contexts.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>