Skip to content

Commit 2ae962a

Browse files
committed
Disable async actions during C API init
1 parent a1f4915 commit 2ae962a

File tree

1 file changed

+9
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+9
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,15 @@ public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context,
928928
try {
929929
if (!context.isCApiInitialized()) {
930930
// loadCApi must set C API context half-way through its execution so that it can
931-
// run code that needs C API context
932-
loadCApi(node, context, name, path, reason);
933-
context.setCApiInitialized(); // volatile write
931+
// run internal Java code that needs C API context
932+
TruffleSafepoint safepoint = TruffleSafepoint.getCurrent();
933+
boolean prevAllowSideEffects = safepoint.setAllowSideEffects(false);
934+
try {
935+
loadCApi(node, context, name, path, reason);
936+
context.setCApiInitialized(); // volatile write
937+
} finally {
938+
safepoint.setAllowSideEffects(prevAllowSideEffects);
939+
}
934940
}
935941
} finally {
936942
initLock.unlock();

0 commit comments

Comments
 (0)