Context
PR #217 removed the generated OpenAPI write stack and introduced the internal RestClient. PR #222 refactored MultiprocessingWriter.
The current multiprocessing implementation still has shutdown and error-handling risks that can cause inconsistent state or a blocked queue.join().
Scope
Improve MultiprocessingWriter reliability:
- Replace the
assert used for runtime state validation with an explicit exception.
- Always call
queue.task_done() when processing a queued write, including failure paths.
- Add an explicit, idempotent
close() method.
- Use
close() from the context manager and keep __del__ as best-effort cleanup only.
- Ensure
on_shutdown is called at most once.
- Handle queue timeout and worker shutdown deterministically.
Tests
Add tests covering:
- writing before
start();
- writing after shutdown;
- worker timeout;
- write failure without a
queue.join() deadlock;
- repeated
close() calls;
- callback invocation count.
Acceptance criteria
- A failed worker write cannot leave
queue.join() blocked indefinitely.
on_shutdown is invoked at most once.
- Shutdown is deterministic for both explicit
close() and context-manager usage.
- Existing multiprocessing behavior remains compatible.
- All unit and integration tests pass.
Out of scope
- Removing multiprocessing support.
- Redesigning batching or retry behavior.
- Adding new InfluxDB endpoints.
- Changes to the public client API beyond the lifecycle and error-handling fixes required here.
Context
PR #217 removed the generated OpenAPI write stack and introduced the internal
RestClient. PR #222 refactoredMultiprocessingWriter.The current multiprocessing implementation still has shutdown and error-handling risks that can cause inconsistent state or a blocked
queue.join().Scope
Improve
MultiprocessingWriterreliability:assertused for runtime state validation with an explicit exception.queue.task_done()when processing a queued write, including failure paths.close()method.close()from the context manager and keep__del__as best-effort cleanup only.on_shutdownis called at most once.Tests
Add tests covering:
start();queue.join()deadlock;close()calls;Acceptance criteria
queue.join()blocked indefinitely.on_shutdownis invoked at most once.close()and context-manager usage.Out of scope