Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb2c7c4

Browse filesBrowse files
authored
bpo-40513: _xxsubinterpreters.run_string() releases the GIL (GH-19944)
In the experimental isolated subinterpreters build mode, _xxsubinterpreters.run_string() now releases the GIL.
1 parent 7be4e35 commit fb2c7c4
Copy full SHA for fb2c7c4

File tree

Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-0
lines changed

‎Modules/_xxsubinterpretersmodule.c

Copy file name to clipboardExpand all lines: Modules/_xxsubinterpretersmodule.c
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,20 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
19391939
return -1;
19401940
}
19411941

1942+
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
1943+
// Switch to interpreter.
1944+
PyThreadState *new_tstate = PyInterpreterState_ThreadHead(interp);
1945+
PyThreadState *save1 = PyEval_SaveThread();
1946+
1947+
(void)PyThreadState_Swap(new_tstate);
1948+
1949+
// Run the script.
1950+
_sharedexception *exc = NULL;
1951+
int result = _run_script(interp, codestr, shared, &exc);
1952+
1953+
// Switch back.
1954+
PyEval_RestoreThread(save1);
1955+
#else
19421956
// Switch to interpreter.
19431957
PyThreadState *save_tstate = NULL;
19441958
if (interp != PyInterpreterState_Get()) {
@@ -1956,6 +1970,7 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
19561970
if (save_tstate != NULL) {
19571971
PyThreadState_Swap(save_tstate);
19581972
}
1973+
#endif
19591974

19601975
// Propagate any exception out to the caller.
19611976
if (exc != NULL) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.