GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update README with thread safety section by lysnikolaou · Pull Request #657 · msgpack/msgpack-python

Conversation

@lysnikolaou

@lysnikolaou lysnikolaou commented Oct 24, 2025

Copy link
Copy Markdown
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
@lysnikolaou
Update README with thread safety section
e9f812c
@methane
methane requested a review from Copilot November 29, 2025 13:56
Copilot started reviewing on behalf of methane November 29, 2025 13:57
View session
Copilot finished reviewing on behalf of methane November 29, 2025 13:58
Copilot AI reviewed Nov 29, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This 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 Packer and Unpacker instances are thread-safe through critical section locking, and provides performance guidance on creating separate instances per thread for optimal performance.

Key changes:

  • Documents thread safety guarantees for Packer and Unpacker instances
  • Explains thread safety of module-level functions like packb() and unpackb()
  • Provides a code example demonstrating the recommended pattern for multi-threaded usage

💡 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
Comment thread README.md
return packer.pack(data)

with ThreadPoolExecutor(max_workers=4) as executor:
results = executor.map(worker, <data>)

Copilot AI Nov 29, 2025

Copy link

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example contains a syntax error with the placeholder <data>. This should be replaced with a concrete example like [1, 2, 3, 4] or data_items to make the example functional and executable.

Suggested change
results = executor.map(worker, <data>)
results = executor.map(worker, [1, 2, 3, 4])

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot uses AI. Check for mistakes.
Comment thread README.md
it may serialize operations due to critical section locking. For optimal
performance in multi-threaded applications, create separate instances per thread:

```python

Copilot AI Nov 29, 2025

Copy link

There was a problem hiding this comment.

Choose a reason for 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.

Suggested change
```python
```py

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clin1234 reacted with thumbs down emoji
All reactions
  • 👎 1 reaction
Copilot uses AI. Check for mistakes.
Comment thread README.md
return packer.pack(data)

with ThreadPoolExecutor(max_workers=4) as executor:
results = executor.map(worker, <data>)

Copilot AI Nov 29, 2025

Copy link

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot uses AI. Check for mistakes.
@lysnikolaou

lysnikolaou commented Dec 23, 2025

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clin1234

clin1234 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@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.

Your wish is about to be fulfilled: https://github.com/msgpack/msgpack-python/releases/tag/v1.2.0
;-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

methane
methane reviewed Jun 12, 2026
View reviewed changes
Comment thread README.md

#### Thread-Safety Guarantees

* **Individual `Packer` and `Unpacker` instances are thread-safe**:

@methane methane Jun 12, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for 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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@lysnikolaou @clin1234 @methane
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.