Skip to content

Use more precise language in discussion about per-module caches - #70

Merged
ngoldbaum merged 1 commit into
Quansight-Labs:mainfrom
ngoldbaum:update-locking-discussion
Sep 3, 2024
Merged

ngoldbaum merged 1 commit into
Quansight-Labs:mainfrom
ngoldbaum:update-locking-discussion

Conversation

@ngoldbaum

Copy link
Copy Markdown
Collaborator

@vafomin asked me about this. I checked with @colesbury, and I think the updated language is closer to the real guarantees people have.

I'm not sure under what circumstances the per-module locks might be released to avoid deadlocks and whether extension authors should worry about that. It's a bit academic for 3.13, because CPython also re-activates the GIL before importing modules with C extensions, but Sam told me users shouldn't rely on that behavior, so I'm not documenting it.

@enotcode

Copy link
Copy Markdown

Wrong tag. I didn't ask for such features :)

@ngoldbaum

Copy link
Copy Markdown
Collaborator Author

Ugh, sorry! I meant to tag @vfdev-5.

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Unrelated to the changes, but the NumPy PR mentioned below uses PyThread_type_lock, presumably because PyMutex wasn't available at the time. Are there any examples we can link to where PyMutex is used, since that is the best practice now? Or do we want to stick to linking to a PR that uses a heap-allocated lock so that we show how to use the init function?

@ngoldbaum
ngoldbaum merged commit da1d037 into Quansight-Labs:main Sep 3, 2024
@ngoldbaum

Copy link
Copy Markdown
Collaborator Author

Unrelated to the changes, but the NumPy PR mentioned below uses PyThread_type_lock, presumably because PyMutex wasn't available at the time. Are there any examples we can link to where PyMutex is used, since that is the best practice now? Or do we want to stick to linking to a PR that uses a heap-allocated lock so that we show how to use the init function?

No we definitely want to use PyMutex. Maybe add a note afterward saying that PyMutex is preferred now?

You could link to the NumPy PR where I switched all the locks to PyMutex: numpy/numpy#27011

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants