📝 clarify async lifecycle docs

This commit is contained in:
Nanaloveyuki
2026-06-14 02:03:34 +08:00
parent 91b0900b11
commit d9b609d064
4 changed files with 21 additions and 10 deletions
+5
View File
@@ -39,6 +39,7 @@ Detailed rules explaining key parameters and behaviors
- `clear=true` immediately closes and abandons pending records.
- In runtimes where shutdown waits for workers, the method then waits until `is_running()` becomes `false` before returning.
- In the current backend split, native-worker runtimes enable both the post-`wait_idle()` clear fallback and the final wait-for-worker phase, while compatibility runtimes skip both extra steps.
- Because `clear=false` delegates to `wait_idle()` first, shutdown can also wait indefinitely when pending records exist but no worker is making progress and no failure flag is raised.
### How to Use
@@ -71,6 +72,8 @@ e.g.:
- In compatibility-style runtimes without background-worker waiting, shutdown still closes the logger but may not perform the extra wait-for-worker phase described for native-worker runtimes.
- If pending work exists but no worker was started, `shutdown(clear=false)` may never reach its later close step because it is still waiting inside `wait_idle()`.
- If callers skip `shutdown()` and only inspect flags manually, it is easier to leave the worker lifecycle in an unclear state.
### Notes
@@ -82,3 +85,5 @@ e.g.:
3. Choose `clear=true` only when loss of queued records is acceptable.
4. Pair it with `state()` or focused counters when tests need to assert whether shutdown drained backlog or converted it into dropped records.
5. Prefer `shutdown(clear=true)` when teardown must not depend on a still-running drain worker.