Skip to content

Commit 122ea61

Browse files
author
David Lassonde
committed
Added delegate for when Python .NET shuts down
1 parent 9caef12 commit 122ea61

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/runtime/pythonengine.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ public static void InitExt()
299299
#endif
300300
}
301301

302+
303+
public delegate void ShutdownDelegate();
304+
public static ShutdownDelegate ShutdownHandler;
305+
302306
/// <summary>
303307
/// Shutdown Method
304308
/// </summary>
@@ -311,13 +315,21 @@ public static void Shutdown()
311315
{
312316
if (initialized)
313317
{
318+
ShutdownHandler();
319+
314320
//////////////////dltrace/////////////////////
315-
/* Exec(@"
316-
import UnityEngine
317-
import threading
318-
UnityEngine.Debug.Log('>>>>>>>>> In PythonEngine.Shutdown() threading.current_thread() = %s'%threading.current_thread())
321+
/*
322+
Exec(@"
323+
import sys
324+
server_path = 'D:/GoogleDrive/ImgSpc/ut/Uni-67748 Brainstorm ideas SG integration, artist can use SG 247/rpyc/pollingServer'
325+
326+
if server_path not in sys.path:
327+
sys.path.append(server_path)
328+
329+
import pollingServer_unity
330+
pollingServer_unity.stop()
319331
");
320-
*/
332+
*/
321333
//////////////////dltrace/////////////////////
322334

323335
//////////////////dltrace/////////////////////
@@ -375,6 +387,11 @@ import UnityEngine
375387
Marshal.FreeHGlobal(_pythonPath);
376388
_pythonPath = IntPtr.Zero;
377389

390+
Exec(@"
391+
import UnityEngine
392+
UnityEngine.Debug.Log('Python.NET is finalizing the runtime')
393+
");
394+
378395
Runtime.Shutdown();
379396

380397

0 commit comments

Comments
 (0)