Skip to content

Commit 50497f9

Browse files
author
taras
committed
Optimize run_in_context calls
1 parent 79d5dcd commit 50497f9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

uvloop/loop.pyx

+15-3
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,35 @@ cdef inline run_in_context(context, method):
9898
# See also: edgedb/edgedb#2222
9999
Py_INCREF(method)
100100
try:
101-
return context.run(method)
101+
Context_Enter(context)
102+
try:
103+
return method()
104+
finally:
105+
Context_Exit(context)
102106
finally:
103107
Py_DECREF(method)
104108

105109

106110
cdef inline run_in_context1(context, method, arg):
107111
Py_INCREF(method)
108112
try:
109-
return context.run(method, arg)
113+
Context_Enter(context)
114+
try:
115+
return method(arg)
116+
finally:
117+
Context_Exit(context)
110118
finally:
111119
Py_DECREF(method)
112120

113121

114122
cdef inline run_in_context2(context, method, arg1, arg2):
115123
Py_INCREF(method)
116124
try:
117-
return context.run(method, arg1, arg2)
125+
Context_Enter(context)
126+
try:
127+
return method(arg1, arg2)
128+
finally:
129+
Context_Exit(context)
118130
finally:
119131
Py_DECREF(method)
120132

0 commit comments

Comments
 (0)