Skip to content

Commit 2c29db7

Browse files
committed
Release the GIL in two places.
1 parent 9efa6da commit 2c29db7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

module.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ static PyObject *object_call(ObjectData *self, PyObject *args, PyObject *kwds) {
9292
jsargs[i] = JS_DupValue(self->context->context, ((ObjectData *)item)->object);
9393
}
9494
}
95-
JSValue value = JS_Call(self->context->context, self->object, JS_NULL, nargs, jsargs);
95+
JSValue value;
96+
Py_BEGIN_ALLOW_THREADS;
97+
value = JS_Call(self->context->context, self->object, JS_NULL, nargs, jsargs);
98+
Py_END_ALLOW_THREADS;
9699
for (int i = 0; i < nargs; ++i) {
97100
JS_FreeValue(self->context->context, jsargs[i]);
98101
}
@@ -174,7 +177,10 @@ static PyObject *context_eval(ContextData *self, PyObject *args) {
174177
if (!PyArg_ParseTuple(args, "s", &code)) {
175178
return NULL;
176179
}
177-
JSValue value = JS_Eval(self->context, code, strlen(code), "<input>", JS_EVAL_TYPE_GLOBAL);
180+
JSValue value;
181+
Py_BEGIN_ALLOW_THREADS;
182+
value = JS_Eval(self->context, code, strlen(code), "<input>", JS_EVAL_TYPE_GLOBAL);
183+
Py_END_ALLOW_THREADS;
178184
return quickjs_to_python(self, value);
179185
}
180186

0 commit comments

Comments
 (0)