Skip to content

Commit 07cdb8f

Browse files
committed
do not release the gil in our internal sources where we implement internals with python code
1 parent 3135db7 commit 07cdb8f

File tree

1 file changed

+10
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime

1 file changed

+10
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import com.oracle.graal.python.nodes.call.CallNode;
6262
import com.oracle.graal.python.nodes.call.GenericInvokeNode;
6363
import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
64+
import com.oracle.graal.python.nodes.function.FunctionRootNode;
6465
import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext;
6566
import com.oracle.graal.python.runtime.exception.ExceptionUtils;
6667
import com.oracle.graal.python.util.PythonUtils;
@@ -73,6 +74,7 @@
7374
import com.oracle.truffle.api.TruffleLanguage.Env;
7475
import com.oracle.truffle.api.TruffleLogger;
7576
import com.oracle.truffle.api.frame.VirtualFrame;
77+
import com.oracle.truffle.api.nodes.RootNode;
7678

7779
/**
7880
* A handler for asynchronous actions events that need to be handled on a main thread of execution,
@@ -263,7 +265,14 @@ protected void perform(ThreadLocalAction.Access access) {
263265
// to tick again later, so we reset the gilReleaseRequested flag even
264266
// when the thread in question isn't actually holding it.
265267
gilReleaseRequested.set(false);
266-
if (access.getLocation().getRootNode() instanceof PClosureRootNode) {
268+
RootNode rootNode = access.getLocation().getRootNode();
269+
if (rootNode instanceof PClosureRootNode) {
270+
if (rootNode.isInternal()) {
271+
return;
272+
}
273+
if (rootNode instanceof FunctionRootNode && ((FunctionRootNode) rootNode).isPythonInternal()) {
274+
return;
275+
}
267276
// we only release the gil in ordinary Python code nodes
268277
GilNode gil = GilNode.getUncached();
269278
if (gil.tryRelease()) {

0 commit comments

Comments
 (0)