Skip to content

Is there any method to get GIL in async? #1912

Discussion options

You must be logged in to vote

it is guaranteed that there is only one coroutine that calls Python::acquire_gil() at the same time

@Easonzero I understand your point however I must disagree still with the implementation. Any number of other threads spawned from Python by threading.Thread, or even Rust threads which are not running async code, may also be waiting on acquire_gil. So I expect it to be very likely that calls to acquire_gil will block even with the companion async Mutex.

For this reason I think offering this API in PyO3 at the moment is misleading to users - if I use an async function from a library I expect it to be guaranteed that the function will never block.

In your own code you are able to control w…

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by davidhewitt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 participants
Converted from issue

This discussion was converted from issue #1891 on October 13, 2021 13:14.