Skip to content

gh-112062: Make _struct module thread-safe in --disable-gil builds #112094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2023
Merged

gh-112062: Make _struct module thread-safe in --disable-gil builds #112094

merged 2 commits into from
Nov 15, 2023

Conversation

chgnrdv
Copy link
Contributor

@chgnrdv chgnrdv commented Nov 14, 2023

Fixes #112062

  • clear cache dict but preserve the reference in _clearcache_impl
  • create cache dict in _structmodule_exec

* use `PyDict_GetItemRef` instead of `PyDict_GetItemWithError` in `cache_struct_converter` to avoid usage of borrowed ref with explicit incref
* clear cache dict but preserve the reference in `_clearcache_impl`
* create cache dict in `_structmodule_exec`
@colesbury
Copy link
Contributor

Thanks @chgnrdv. This is going to conflict with @serhiy-storchaka's #112076, which also makes _struct.c use PyDict_GetItemRef.

Maybe remove that part and just keep the changes to _clearcache_impl and _structmodule_exec?

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Thanks, this lgtm. @kumaraditya303, would you please review this change?

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM

@kumaraditya303 kumaraditya303 merged commit 4744f59 into python:main Nov 15, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
… builds (python#112094)

* pythongh-112062: Make `_struct` module thread-safe in --disable-gil builds
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
… builds (python#112094)

* pythongh-112062: Make `_struct` module thread-safe in --disable-gil builds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make _struct module thread-safe in --disable-gil builds
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy