Skip to content

Commit 695d569

Browse files
Add initialization logs
1 parent 37ddac6 commit 695d569

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/runtime/pythonengine.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -164,6 +164,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
164164
// during an initial "import clr", and the world ends shortly thereafter.
165165
// This is probably masking some bad mojo happening somewhere in Runtime.Initialize().
166166
delegateManager = new DelegateManager();
167+
Console.WriteLine("PythonEngine.Initialize(): Runtime.Initialize()...");
167168
Runtime.Initialize();
168169
initialized = true;
169170
Exceptions.Clear();
@@ -179,9 +180,11 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
179180
string code =
180181
"import atexit, clr\n" +
181182
"atexit.register(clr._AtExit)\n";
183+
Console.WriteLine("PythonEngine.Initialize(): register atexit callback...");
182184
PythonEngine.Exec(code);
183185

184186
// Load the clr.py resource into the clr module
187+
Console.WriteLine("PythonEngine.Initialize(): GetCLRModule()...");
185188
IntPtr clr = Python.Runtime.ImportHook.GetCLRModule();
186189
IntPtr clr_dict = Runtime.PyModule_GetDict(clr);
187190

@@ -193,6 +196,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
193196
IntPtr builtins = Runtime.PyEval_GetBuiltins();
194197
Runtime.PyDict_SetItemString(module_globals, "__builtins__", builtins);
195198

199+
Console.WriteLine("PythonEngine.Initialize(): clr GetManifestResourceStream...");
196200
Assembly assembly = Assembly.GetExecutingAssembly();
197201
using (Stream stream = assembly.GetManifestResourceStream("clr.py"))
198202
using (var reader = new StreamReader(stream))

src/runtime/runtime.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,18 @@ internal static void Initialize()
213213
{
214214
if (Py_IsInitialized() == 0)
215215
{
216+
Console.WriteLine("Runtime.Initialize(): Py_Initialize...");
216217
Py_Initialize();
217218
MainManagedThreadId = Thread.CurrentThread.ManagedThreadId;
218219
}
219220

220221
if (PyEval_ThreadsInitialized() == 0)
221222
{
223+
Console.WriteLine("Runtime.Initialize(): PyEval_InitThreads...");
222224
PyEval_InitThreads();
223225
}
224226

227+
Console.WriteLine("Runtime.Initialize(): Initialize types...");
225228
IntPtr op;
226229
IntPtr dict;
227230
if (IsPython3)
@@ -326,6 +329,7 @@ internal static void Initialize()
326329
XDecref(c);
327330
XDecref(d);
328331
#endif
332+
Console.WriteLine("Runtime.Initialize(): Initialize types end.");
329333

330334
Error = new IntPtr(-1);
331335

@@ -343,7 +347,7 @@ internal static void Initialize()
343347
NativeMethods.FreeLibrary(dllLocal);
344348
}
345349
#endif
346-
350+
Console.WriteLine("Runtime.Initialize(): AssemblyManager.Initialize()...");
347351
// Initialize modules that depend on the runtime class.
348352
AssemblyManager.Initialize();
349353
PyCLRMetaType = MetaType.Initialize();
@@ -357,6 +361,7 @@ internal static void Initialize()
357361
IntPtr item = PyString_FromString(rtdir);
358362
PyList_Append(path, item);
359363
XDecref(item);
364+
Console.WriteLine("Runtime.Initialize(): AssemblyManager.UpdatePath()...");
360365
AssemblyManager.UpdatePath();
361366
}
362367

0 commit comments

Comments
 (0)