File tree Expand file tree Collapse file tree 1 file changed +4
-21
lines changed
Expand file tree Collapse file tree 1 file changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -23,18 +23,8 @@ public unsafe static int Initialize(IntPtr data, int size)
2323 PythonDLL = null ;
2424 }
2525
26- var gs = PyGILState_Ensure ( ) ;
27-
28- try
29- {
30- // Console.WriteLine("Startup thread");
31- PythonEngine . InitExt ( ) ;
32- // Console.WriteLine("Startup finished");
33- }
34- finally
35- {
36- PyGILState_Release ( gs ) ;
37- }
26+ using var _ = Py . GIL ( ) ;
27+ PythonEngine . InitExt ( ) ;
3828 }
3929 catch ( Exception exc )
4030 {
@@ -55,15 +45,8 @@ public unsafe static int Shutdown(IntPtr data, int size)
5545
5646 if ( command == "full_shutdown" )
5747 {
58- var gs = PyGILState_Ensure ( ) ;
59- try
60- {
61- PythonEngine . Shutdown ( ) ;
62- }
63- finally
64- {
65- PyGILState_Release ( gs ) ;
66- }
48+ using var _ = Py . GIL ( ) ;
49+ PythonEngine . Shutdown ( ) ;
6750 }
6851 }
6952 catch ( Exception exc )
You can’t perform that action at this time.
0 commit comments