Document and test multiprocessing pattern for concurrent XML loading#58
Merged
Merged
Conversation
Documents and tests the pattern of using a multiprocessing.Lock to allow parallel XML parsing while serialising DuckDB writes to a shared file-based database. Each worker process gets its own DataModel (unique temp_prefix UUID), so temp tables never collide. engine.dispose() is called inside the lock to release the file handle before the next writer acquires it. https://claude.ai/code/session_01JB3CkHnBDM3aQP2EHhfzjv
After all worker processes finish loading, verify each file by extracting it from the database and comparing the regenerated XML byte-for-byte with the original. Uses the same model config as the orders roundtrip test (version 0) so the assertion is meaningful. https://claude.ai/code/session_01JB3CkHnBDM3aQP2EHhfzjv
Open with the general principle (serialise DB access across processes) and explain why the level of required synchronisation differs per backend, before presenting the DuckDB-as-concrete-example snippet. Also rename db_path → connection_string in the code sample to remove the DuckDB-specific string construction. https://claude.ai/code/session_01JB3CkHnBDM3aQP2EHhfzjv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a test_multiprocessing.py test (parallel parse + serialised DuckDB writes via multiprocessing.Lock, with XML roundtrip content assertion) and a matching example in the API overview docs. Each worker creates its own DataModel with a unique temp_prefix so temp tables never collide. Bumps version to 0.13.1.