diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx index f9a5a239..fc3dbff3 100644 --- a/uvloop/loop.pyx +++ b/uvloop/loop.pyx @@ -92,31 +92,27 @@ 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 - Py_INCREF(method) + Context_Enter(context) try: - return context.run(method) + return method() finally: - Py_DECREF(method) + Context_Exit(context) cdef inline run_in_context1(context, method, arg): - Py_INCREF(method) + Context_Enter(context) try: - return context.run(method, arg) + return method(arg) finally: - Py_DECREF(method) + Context_Exit(context) cdef inline run_in_context2(context, method, arg1, arg2): - Py_INCREF(method) + Context_Enter(context) try: - return context.run(method, arg1, arg2) + return method(arg1, arg2) finally: - Py_DECREF(method) + Context_Exit(context) # Used for deprecation and removal of `loop.create_datagram_endpoint()`'s