| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
- Use Double-Checked Locking and Copy-on-Write in Marshal.__new__ - Use getattr safely in BaseMarshal.get_rule - Add tests for concurrency scenarios Fixes #15100
There was a problem hiding this comment.
This pull request introduces thread-safety improvements to the Marshal class, implementing a threading lock, double-checked locking, and copy-on-write dictionary updates to prevent race conditions and dictionary mutation errors during iteration. It also adds safety checks for uninitialized instances and a comprehensive test suite. The review feedback recommends using unittest.mock.patch.dict in the tests to safely modify Marshal._instances and avoid potential test pollution if a test fails.
Sorry, something went wrong.
…tests Follows reviewer suggestion to avoid potential test pollution.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Thread-safe Marshal Initialization
Problem
A RuntimeError saying dictionary changed size during iteration can occur randomly in BaseMarshal.get_rule. This happens because one thread is reading the _instances dictionary while another thread is adding a new instance to it. This is common when using features like Firestore's on_snapshot in a background thread.
Solution
Notes to Reviewers
Fixes #15100