-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
cython tasks are KI protected #3122
Comments
this is because Cython coroutines appear to have a frame, so it doesn't get a wrapper python coroutine: Lines 1859 to 1867 in 57452ad
but don't actually push that frame when the coroutine runs I think we need to check |
Should this be raised as a Cython bug? (I know that doesn't help us in the meanwhile but having an attribute in some cases but not all is not useful)
I assume this would undo any sort of KI protection enabled by outer scopes, because it's impossible to know whether it's enabling or disabling KI protection? I think that makes sense, though maybe it would be better to detect that the frame will not be there and then create a wrapper, unless @enable_ki_protection
async def bad():
sleep() |
We could have two async wrappers for cython, one protected and one unprotected, and use the KI protected-ness of the coro.cr_frame.co_code to pick which one you use This would not work for cases like this: @enable_ki_protection
async def bad():
sleep()
async def outer():
return await bad() |
The other option is for enable_ki_protection to detect cython functions and wrap them with an extra (async, generator,asyncgenerater)function |
I think detecting Cython functions and wrapping then would ultimately be simpler and that's better.
I don't get what you mean by this, though I'm also tired so it could be that too. |
OK so looking at this more, in general
import sys
def synctest():
print(sys._getframe(0))
def synctestwrapper():
synctest() in a REPL: >>> import hello
>>> hello.synctest()
<frame at 0x00000166F3D6A200, file '<stdin>', line 1, code <module>>
>>> hello.synctestwrapper()
<frame at 0x00000166F3D6A200, file '<stdin>', line 1, code <module>> Looking at cython's limitations page, this is intentional:
Given that, I think we should create a wrapper around things if That somewhat negates the benefits of using the |
if you write a python function:
and call it from a cython task:
it hangs forever and can't be interrupted with ctrl+c
currently_ki_protected sees the following stack:
The text was updated successfully, but these errors were encountered: