Skip to content

Commit e367c4a

Browse files
committed
Remove GILState guards
Life is simpler without it. We will see after we really start using Python
1 parent ab0ccf7 commit e367c4a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Tool/Sources/PythonHelper/RunPython.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public func initializePython<GilState, ThreadState>(
3333
isPythonInitialized = true
3434
// Initialize python
3535
Py_Initialize()
36-
// Immediately release the thread, so that we can ensure the GIL state later.
37-
// We may not recover the thread because all future tasks will be done in the other threads.
38-
_ = PyEval_SaveThread()
39-
// Setup GIL state guard.
40-
gilStateEnsure = { PyGILState_Ensure() }
41-
gilStateRelease = { gilState in PyGILState_Release(gilState as! GilState) }
36+
// // Immediately release the thread, so that we can ensure the GIL state later.
37+
// // We may not recover the thread because all future tasks will be done in the other threads.
38+
// _ = PyEval_SaveThread()
39+
// // Setup GIL state guard.
40+
// gilStateEnsure = { PyGILState_Ensure() }
41+
// gilStateRelease = { gilState in PyGILState_Release(gilState as! GilState) }
4242
}
4343

4444
public func runPython<T>(
@@ -47,14 +47,14 @@ public func runPython<T>(
4747
) throws -> T {
4848
if usePythonThread {
4949
return try PythonThread.shared.runPythonAndWait {
50-
return try gilStateGuard {
51-
try closure()
52-
}
50+
// return try gilStateGuard {
51+
return try closure()
52+
// }
5353
}
5454
} else {
55-
return try gilStateGuard {
56-
try closure()
57-
}
55+
// return try gilStateGuard {
56+
return try closure()
57+
// }
5858
}
5959
}
6060

0 commit comments

Comments
 (0)