mirror of https://github.com/MagicStack/uvloop.git
Don't increase refcount in run_in_context since cython does it for us
This commit is contained in:
parent
54ac4f5947
commit
b5873d5131
|
@ -92,36 +92,26 @@ cdef inline socket_dec_io_ref(sock):
|
|||
|
||||
|
||||
cdef inline run_in_context(context, method):
|
||||
# This method is internally used to workaround a reference issue that in
|
||||
# certain circumstances, inlined context.run() will not hold a reference to
|
||||
# the given method instance, which - if deallocated - will cause segfault.
|
||||
# See also: edgedb/edgedb#2222
|
||||
Context_Enter(context)
|
||||
Py_INCREF(method)
|
||||
try:
|
||||
return method()
|
||||
finally:
|
||||
Py_DECREF(method)
|
||||
Context_Exit(context)
|
||||
|
||||
|
||||
cdef inline run_in_context1(context, method, arg):
|
||||
Context_Enter(context)
|
||||
Py_INCREF(method)
|
||||
try:
|
||||
return method(arg)
|
||||
finally:
|
||||
Py_DECREF(method)
|
||||
Context_Exit(context)
|
||||
|
||||
|
||||
cdef inline run_in_context2(context, method, arg1, arg2):
|
||||
Context_Enter(context)
|
||||
Py_INCREF(method)
|
||||
try:
|
||||
return method(arg1, arg2)
|
||||
finally:
|
||||
Py_DECREF(method)
|
||||
Context_Exit(context)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue