@@ -83,6 +83,8 @@ public static void RunPython() {
83
83
AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
84
84
string name = AppDomain.CurrentDomain.FriendlyName;
85
85
Console.WriteLine(string.Format(""[{0} in .NET] In PythonRunner.RunPython"", name));
86
+ Console.Out.Flush();
87
+
86
88
using (Py.GIL()) {
87
89
try {
88
90
var pyScript = string.Format(""import clr\n""
@@ -96,11 +98,13 @@ public static void RunPython() {
96
98
PythonEngine.Exec(pyScript);
97
99
} catch(Exception e) {
98
100
Console.WriteLine(string.Format(""[{0} in .NET] Caught exception: {1}"", name, e));
101
+ Console.Out.Flush();
99
102
}
100
103
}
101
104
}
102
105
static void OnDomainUnload(object sender, EventArgs e) {
103
- System.Console.WriteLine(string.Format(""[{0} in .NET] unloading"", AppDomain.CurrentDomain.FriendlyName));
106
+ Console.WriteLine(string.Format(""[{0} in .NET] unloading"", AppDomain.CurrentDomain.FriendlyName));
107
+ Console.Out.Flush();
104
108
}
105
109
}" ;
106
110
@@ -156,13 +160,15 @@ public void InitAssembly(string assemblyPath)
156
160
public void RunPython ( )
157
161
{
158
162
Console . WriteLine ( "[Proxy] Entering RunPython" ) ;
163
+ Console . Out . Flush ( ) ;
159
164
160
165
// Call into the new assembly. Will execute Python code
161
166
var pythonrunner = theAssembly . GetType ( "PythonRunner" ) ;
162
167
var runPythonMethod = pythonrunner . GetMethod ( "RunPython" ) ;
163
168
runPythonMethod . Invoke ( null , new object [ ] { } ) ;
164
169
165
170
Console . WriteLine ( "[Proxy] Leaving RunPython" ) ;
171
+ Console . Out . Flush ( ) ;
166
172
}
167
173
}
168
174
@@ -173,6 +179,7 @@ public void RunPython()
173
179
static void RunAssemblyAndUnload ( Assembly assembly , string assemblyName )
174
180
{
175
181
Console . WriteLine ( $ "[Program.Main] === creating domain for assembly { assembly . FullName } ") ;
182
+ Console . Out . Flush ( ) ;
176
183
177
184
// Create the domain. Make sure to set PrivateBinPath to a relative
178
185
// path from the CWD (namely, 'bin').
@@ -203,17 +210,21 @@ static void RunAssemblyAndUnload(Assembly assembly, string assemblyName)
203
210
theProxy . RunPython ( ) ;
204
211
205
212
Console . WriteLine ( $ "[Program.Main] Before Domain Unload on { assembly . FullName } ") ;
213
+ Console . Out . Flush ( ) ;
206
214
AppDomain . Unload ( domain ) ;
207
215
Console . WriteLine ( $ "[Program.Main] After Domain Unload on { assembly . FullName } ") ;
216
+ Console . Out . Flush ( ) ;
208
217
209
218
// Validate that the assembly does not exist anymore
210
219
try
211
220
{
212
221
Console . WriteLine ( $ "[Program.Main] The Proxy object is valid ({ theProxy } ). Unexpected domain unload behavior") ;
222
+ Console . Out . Flush ( ) ;
213
223
}
214
224
catch ( Exception )
215
225
{
216
226
Console . WriteLine ( "[Program.Main] The Proxy object is not valid anymore, domain unload complete." ) ;
227
+ Console . Out . Flush ( ) ;
217
228
}
218
229
}
219
230
0 commit comments