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
edgedb-python test fails with uvloop 0.15.0 #2222
Comments
Potential fix: (patches uvloop) cdef main(T tt):
ctx = contextvars.copy_context()
run = tt._run
ctx.run(run) or (patches edgedb) def run(self):
t = self.t
t.clear() I think patching uvloop makes more sense - as |
Is this a Cython bug then? |
No, I don't think so - if we're calling UPDATE: looking at some CPython implementations, e.g. |
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
With more debugging, this looks more like a Cython bug to me now. I'll update with more details |
@fantix, check upstream master branch/issues too. It is likely that they've fixed this already, just haven't released. |
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
TL;DR: uvloop 0.15.1 should've fixed this issue on our end. I'll create an issue in Cython to continue the discussion there. Below is an incremental list of things I tried so far:
Details: TBD |
I think this has been fixed and can be closed. |
Seems like asyncio in Python 3.11 has a similar issue? https://github.com/MagicStack/uvloop/runs/7822201198?check_suite_focus=true#step:7:768 |
OK so there are 2 issues here.
In Python 3.9 or lower, Cython uses a fast C-call method to call This difference led to the explained issue at the very beginning in Python 3.9, and the issue was fixed in uvloop by INCREFing the args manually. Still, this is an issue in Cython anyways I think (?).
The test in uvloop however is simulating the Cython issue with a weakref, a simplified version looks like this: import weakref
a = None
class A:
def __init__(self):
self.v = 42
def f(self):
self = weakref.ref(self)
global a
a = None
print(self().v)
a = A()
a.f() This passes in Python 3.10 and below but fails on 3.11 because of the new Python call implementation I think, so it is not an issue in 3.11 asyncio because the For now I will skip this uvloop test in 3.10 and above, and seek a fix in Cython for 3.9 and lower. |
Because `context.run()` doesn't hold reference to the callable, when e.g. the protocol is written in Cython, the callbacks were not guaranteed to hold the protocol reference. This PR fixes the issue by explicitly add a reference before `context.run()` calls. Refs edgedb/edgedb#2222
This is reproducible without edgedb/uvloop using a Cython script, which illustrates how edgedb/uvloop 0.15 run:
The text was updated successfully, but these errors were encountered: