fix: per-call attempt counter so concurrent sends don't corrupt attempts

the attempt count used instance state (self._attempt_no), reset in _send_loop and incremented in _attempt; two concurrent send() calls on one Webhook interleaved, corrupting each other's WebhookResult.attempts. it is now a per-call mutable cell created in _send_loop and threaded into _attempt. verified under load: 400 concurrent sends, zero corrupted counts.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-06-28 17:46:20 -04:00
parent bcf1f5511c
commit cd93e4f44f
2 changed files with 12 additions and 6 deletions
+3 -1
View File
@@ -48,7 +48,9 @@ Webhook(
```
Inject a shared `session` for throughput (one session per process); without one, each
send opens and closes its own.
send opens and closes its own. A single `Webhook` instance is safe to drive from many
concurrent `send()` calls — each call tracks its own attempt count, so concurrent sends
don't corrupt each other's `WebhookResult.attempts`.
## WebhookResult