| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Codecov Report❌ Patch coverage is 95.22184% with 14 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## master #643 +/- ##
==========================================
+ Coverage 82.49% 83.92% +1.42%
==========================================
Files 69 69
Lines 2697 2943 +246
==========================================
+ Hits 2225 2470 +245
- Misses 472 473 +1 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
Ensure post_send completes before local execution while preserving per-invocation ownership and await_inplace semantics. Drain accepted tasks during shutdown, retain background failures, and clean up middleware, result backend, and executor resources reliably. Add concurrency, cancellation, lifecycle, and compatibility coverage. Closes: #586
Identify producer and consumer spans by SpanKind instead of relying on platform-dependent start-time ordering, fixing Windows CI failures.
Preserve accepted work across hook failures and cancellation. Drain broker-owned tasks before closing lifecycle resources. Move executor shutdown off the event loop and retain first failures. Add deterministic ordering, concurrency, and shutdown coverage. Refs: #586
| Back | FazBrowse Home | New Git URL |
Ensure post_send completes before local execution while preserving per-invocation ownership and await_inplace semantics.
Drain accepted tasks during shutdown, retain background failures, and clean up middleware, result backend, and executor resources reliably.
Add concurrency, cancellation, lifecycle, and compatibility coverage.
Closes: #586
Why This Approach Differs from #639
PR #639 correctly identifies the original problem and the required hook ordering. However, its implementation covers only the sequential happy path and does not establish reliable ownership of locally executed tasks.
Per-Invocation Ownership
PR #639 stores inline tasks in a broker-wide _inplace_tasks set shared by all concurrent .kiq() calls. One invocation can therefore collect and await another invocation’s task, while the second invocation observes an empty set and returns before its own task completes.
This breaks the per-invocation contract of await_inplace=True.
The current implementation assigns each invocation its own execution task and synchronization gate. Every caller waits only for the work it submitted.
Strict post_send Ordering
Creating the receiver with asyncio.create_task() before running post_send does not guarantee strict ordering. When an asynchronous post_send hook suspends, the event loop may start pre_execute and the task body concurrently.
The implementation in this PR keeps the receiver behind a per-invocation gate. Execution cannot begin until the complete post_send middleware chain for that invocation has finished.
Error and Cancellation Ownership
If post_send fails or is cancelled after the message has been accepted, the execution task still needs an explicit owner.
This implementation transfers such work to broker-managed background ownership. wait_all() and shutdown() can then drain it and propagate execution failures instead of leaving detached tasks behind.
It also preserves the existing cancellation behavior for normal inline execution.
Lifecycle Integration
The ownership model is integrated with the complete InMemoryBroker lifecycle:
Test Coverage
The behavior is protected by deterministic tests covering:
The additional implementation is therefore not ceremony around hook ordering. It defines the complete lifecycle of an accepted message: gated execution, per-invocation or broker ownership, failure propagation, draining, and cleanup.