Skip to content

Release GIL when polling Runtime API for next invocation #33

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 1 commit into from
May 26, 2021

Conversation

carlzogh
Copy link
Contributor

Notes

runtime_client is holding the GIL (Global Interpreter Lock) while it is polling for the runtime/invocation/next invocation, which is meant to be an async I/O operation.

According to the Python extension docs on Initialization, Finalization, and Threads, any blocking I/O should release the lock explicitly to allow other code to continue. This is especially true for extensions where developers (us, in this case) should manage releasing/reacquiring the lock.

Without the lock, even the simplest operations could cause problems in a multi-threaded program: for example, when two threads simultaneously increment the reference count of the same object, the reference count could end up being incremented only once instead of twice.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@carlzogh carlzogh force-pushed the main branch 2 times, most recently from 7b6518d to 81a0f9f Compare May 26, 2021 10:55
@carlzogh carlzogh added enhancement New feature or request semver-patch Requires a patch semantic versioning bump labels May 26, 2021
@carlzogh carlzogh requested review from edhzsz and preearor May 26, 2021 11:15
Copy link
Contributor

@zsombor-balogh zsombor-balogh left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-patch Requires a patch semantic versioning bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants