Skip to content

Fixes to integrate pythonnet into Unity #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
410ac15
UNI-63112: unit test for the domain reload crash
Sep 14, 2018
c07fff0
UNI-62864: shutdown on domain reload.
Sep 14, 2018
d016b24
Drive-by improve a hashtable to hashset.
Sep 26, 2018
9ae91ba
UNI-63112: implement platform-aware native code for tp_traverse et al
Sep 26, 2018
bb76ff3
Domain reload work: port previous commit to Windows
benoithudson Sep 28, 2018
0c5b78f
Fixed a bogus comment.
benoithudson Sep 28, 2018
9ffb705
Make prettier
benoithudson Sep 28, 2018
2e03eb8
Added author and changelog information.
Sep 28, 2018
156f554
Fix for linux mmap requiring MAP_PRIVATE
benoithudson Oct 2, 2018
84f5087
Doc and typo fixes.
benoithudson Oct 2, 2018
b9f6c2c
Merge branch 'uni-63112-hotreload-crash-test' of https://github.com/U…
benoithudson Oct 2, 2018
e585bdc
Merge pull request #7 from Unity-Technologies/uni-63112-hotreload-cra…
benoithudson Oct 2, 2018
9ab7b13
Disable app domain test case on .NET Standard
Oct 3, 2018
13f8b53
Fix for CI: define NETSTANDARD in src/embed_tests
Oct 3, 2018
c0b52fa
Fix compile error on OSX that came from an upstream merge.
Oct 3, 2018
4096a95
Fix in dotnet code path: find mmap in libc rather than __Internal
Oct 3, 2018
9b74cce
Fix TypeManager test for running on .NET Core under linux/OSX
Oct 3, 2018
5e15b2c
Fix for python3 tests crashing: it's about test order
Oct 4, 2018
211155e
WIP - debug: turn off "quiet" so that I get an error message
Oct 11, 2018
14bc2e2
Use msbuild v14 for linux/darwin.
Oct 11, 2018
8a80fd5
Upgrade setuptools on appveyor
Oct 11, 2018
dd77fa5
Flush the console on every WriteLine so messages are in order.
Oct 11, 2018
f947e3b
Grasping at straws: try using conda to set up environment
Oct 11, 2018
1fda82b
Revert "Grasping at straws: try using conda to set up environment"
Oct 11, 2018
ec6f6c5
Give up on python 3.4 for appveyor.
Oct 11, 2018
4bac40e
Travis: don't print from domain-reload test
Oct 11, 2018
386a034
Fixed appveyor "allow_failures" syntax.
Oct 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UNI-62864: shutdown on domain reload.
Shut down python when the domain that loaded python reloads.
  • Loading branch information
Benoit Hudson committed Sep 14, 2018
commit c07fff02f4fe30a725e8df1b3aaab3aa2a87ff97
4 changes: 4 additions & 0 deletions src/embed_tests/TestDomainReload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.CodeDom.Compiler;
using System.Reflection;
using NUnit.Framework;
using Python.Runtime;

namespace Python.EmbeddingTest
{
Expand Down Expand Up @@ -48,6 +49,9 @@ public static void DomainReloadAndGC()
Assembly pythonRunner1 = BuildAssembly("test1");
RunAssemblyAndUnload(pythonRunner1, "test1");

// Verify that python is not initialized even though we ran it.
Assert.That(Runtime.Runtime.Py_IsInitialized(), Is.Zero);

// This caused a crash because objects allocated in pythonRunner1
// still existed in memory, but the code to do python GC on those
// objects is gone.
Expand Down
10 changes: 10 additions & 0 deletions src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,17 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
{
locals.Dispose();
}

// Make sure we clean up properly on app domain unload.
AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
}
}

static void OnDomainUnload(object _, EventArgs __)
{
Shutdown();
}

/// <summary>
/// A helper to perform initialization from the context of an active
/// CPython interpreter process - this bootstraps the managed runtime
Expand Down Expand Up @@ -303,6 +311,8 @@ public static void Shutdown()
_pythonPath = IntPtr.Zero;

Runtime.Shutdown();

AppDomain.CurrentDomain.DomainUnload -= OnDomainUnload;
initialized = false;
}
}
Expand Down