Skip to content
Closed
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ on_finish:

artifacts:
- path: dist\*
- path: TestResult.xml
name: TestResult
type: xml

notifications:
- provider: Slack
Expand Down
1 change: 1 addition & 0 deletions src/embed_tests/Python.EmbeddingTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="TestConsoleInterrupt.cs" />
<Compile Include="dynamic.cs" />
<Compile Include="pyimport.cs" />
<Compile Include="pyinitialize.cs" />
Expand Down
Binary file added src/embed_tests/TestConsoleInterrupt.cs
Binary file not shown.
9 changes: 5 additions & 4 deletions src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public static void Initialize()
Initialize(setSysArgv: true);
}

public static void Initialize(bool setSysArgv = true)
public static void Initialize(bool setSysArgv = true, bool initSigs = false)
{
Initialize(Enumerable.Empty<string>(), setSysArgv: setSysArgv);
Initialize(Enumerable.Empty<string>(), setSysArgv: setSysArgv, initSigs: initSigs);
}

/// <summary>
Expand All @@ -153,8 +153,9 @@ public static void Initialize(bool setSysArgv = true)
/// more than once, though initialization will only happen on the
/// first call. It is *not* necessary to hold the Python global
/// interpreter lock (GIL) to call this method.
/// initSigs can be set to 1 to do default python signal configuration. This will override the way signals are handled by the application.
/// </remarks>
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true, bool initSigs = false)
{
if (!initialized)
{
Expand All @@ -164,7 +165,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
// during an initial "import clr", and the world ends shortly thereafter.
// This is probably masking some bad mojo happening somewhere in Runtime.Initialize().
delegateManager = new DelegateManager();
Runtime.Initialize();
Runtime.Initialize(initSigs);
initialized = true;
Exceptions.Clear();

Expand Down
7 changes: 5 additions & 2 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ public class Runtime
/// <summary>
/// Initialize the runtime...
/// </summary>
internal static void Initialize()
internal static void Initialize(bool initSigs)
{
if (Py_IsInitialized() == 0)
{
Py_Initialize();
Py_InitializeEx(initSigs ? 1 : 0);
}

if (PyEval_ThreadsInitialized() == 0)
Expand Down Expand Up @@ -604,6 +604,9 @@ internal static unsafe long Refcount(IntPtr op)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_Initialize();

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void Py_InitializeEx(int initsigs);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int Py_IsInitialized();

Expand Down