@@ -56,8 +56,8 @@ public static void DomainReloadAndGC()
5656 Assembly pythonRunner1 = BuildAssembly ( "test1" ) ;
5757 RunAssemblyAndUnload ( pythonRunner1 , "test1" ) ;
5858
59- // Verify that python is not initialized even though we ran it.
60- //Assert.That(Runtime.Runtime.Py_IsInitialized(), Is.Zero );
59+ Assert . That ( Runtime . Runtime . Py_IsInitialized ( ) != 0 ,
60+ "On soft-shutdown mode, Python runtime should still running" ) ;
6161
6262 // This caused a crash because objects allocated in pythonRunner1
6363 // still existed in memory, but the code to do python GC on those
@@ -83,7 +83,7 @@ public static void RunPython() {
8383 AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
8484 string name = AppDomain.CurrentDomain.FriendlyName;
8585 Console.WriteLine(string.Format(""[{0} in .NET] In PythonRunner.RunPython"", name));
86- // PythonEngine.Initialize(softShutdown: true);
86+ PythonEngine.Initialize(softShutdown: true);
8787 using (Py.GIL()) {
8888 try {
8989 var pyScript = string.Format(""import clr\n""
@@ -99,6 +99,7 @@ public static void RunPython() {
9999 Console.WriteLine(string.Format(""[{0} in .NET] Caught exception: {1}"", name, e));
100100 }
101101 }
102+ PythonEngine.BeginAllowThreads();
102103 }
103104 static void OnDomainUnload(object sender, EventArgs e) {
104105 System.Console.WriteLine(string.Format(""[{0} in .NET] unloading"", AppDomain.CurrentDomain.FriendlyName));
0 commit comments