GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Update README with thread safety section by lysnikolaou · Pull Request #657 · msgpack/msgpack-python Conversation
Contributor
Since the next version is going to be supporting the free-threaded build, I thought it might be nice to have a note about it in the README. If it's desirable, I can also update the docs.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewThis PR adds documentation to the README explaining thread safety guarantees for msgpack when used with CPython 3.14's free-threaded build (PEP 703). The documentation clarifies that Key changes:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
| results = executor.map(worker, <data>) | |
| results = executor.map(worker, [1, 2, 3, 4]) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| it may serialize operations due to critical section locking. For optimal | ||
| performance in multi-threaded applications, create separate instances per thread: | ||
|
|
||
| ```python |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The code block uses python which is inconsistent with the existing README convention. Other non-interactive code examples in this README use py (see lines 60, 81). For consistency, this should be changed to ```py.
| ```python | |
| ```py |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return packer.pack(data) | ||
|
|
||
| with ThreadPoolExecutor(max_workers=4) as executor: | ||
| results = executor.map(worker, <data>) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The new thread safety documentation and recommended usage pattern lacks test coverage. Consider adding a test case that validates thread-safe usage of Packer and Unpacker instances across multiple threads, similar to the example provided in the documentation.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@methane A gentle ping on this. I don't think the Copilot comments are very relevant and I still feel this PR is ready to go. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Your wish is about to be fulfilled: https://github.com/msgpack/msgpack-python/releases/tag/v1.2.0 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| #### Thread-Safety Guarantees | ||
|
|
||
| * **Individual `Packer` and `Unpacker` instances are thread-safe**: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
thread-safe is a very strong guarantee. Packer and Unpacker are designed to not crash when used from multiple threads, but the correctness of the output depends on the types and timing of the methods being called simultaneously.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.