Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CTRL+C stops working after importing the signal module #2102

Open
@rmadsen-ks

Description

@rmadsen-ks
importsignal

seems to break C# CTRL+C signal handling.

Environment

  • Pythonnet version:
  • Python version: 3.11
  • Operating System: Windows 11
  • .NET Runtime: 478

Details

I want to shut down the process by calling CTRL+C. That signal is intercepted from C# to call some additional logic.

However, it seems like after importing the signal module, the signal handler no longer works.

I was able to reproduce the issue modifying only the Pythonnet Console project the following way:

The following works:

// Main() ...string[]cmd=Environment.GetCommandLineArgs();PythonEngine.Initialize(false,false);Py.Import("os");// note, here the 'os' module is imported.Console.WriteLine("Waiting 5 sec. Verify if CTRL+C exits the application");System.Threading.Thread.Sleep(5000);inti=0;// int i = Runtime.Py_Main(cmd.Length, cmd);PythonEngine.Shutdown();returni;

The following does not work:

// Main() ...string[]cmd=Environment.GetCommandLineArgs();PythonEngine.Initialize();Py.Import("signal");//here the signal  module gets imported.Console.WriteLine("Waiting 5 sec. Verify if CTRL+C exits the application");System.Threading.Thread.Sleep(5000);inti=0;// int i = Runtime.Py_Main(cmd.Length, cmd);PythonEngine.Shutdown();returni;

This might be the same as:#1746

Except I have not been able to reproduce the issue with numpy.

This seems like something that if it cannot be fixed, at least it should be documented how to work around it.

This also sounds a bit like#449, but that is a different issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp