-
Notifications
You must be signed in to change notification settings - Fork 750
Call to Py_Initialize changes signal handler configuration #449
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
Comments
@rmadsen-ks this change looks reasonable! Can you submit a pull request? |
@denfromufa, sure, I can do that tomorrow.
|
1. Yes
According to the linked docs that your provided this Py_InitializeEx should
be the preferred way when embedding CPython.
However we should keep the old option as optional argument, in case someone
handles this somehow with Python exception.
So I would add deprecating warning to mention that next version we would
switch to recommended C-API behavior.
2.
You can actually start your pull request with the unit test to show that
the current implementation of Py_Initialize fails to interrupt with Ctrl+C.
And then add the implementation once the failure is obviously from both
Appveyor and Travis CI.
As a side note so you cannot capture Ctrl+C from Python exception currently?
…On Tue, Apr 4, 2017, 9:48 AM rmadsen-ks ***@***.***> wrote:
@denfromufa <https://github.com/denfromufa>, sure, I can do that tomorrow.
1. Should it be an optional argument to PythonEngine.Initialize?
2. Should there be a unit test testing the issue? (might be very
complicated to implement)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#449 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgZ5UGc8wGPb78GICB4uAm-FWls9Y3nks5rslg4gaJpZM4MyzCi>
.
|
4 tasks
filmor
pushed a commit
to filmor/pythonnet
that referenced
this issue
Aug 21, 2018
…thonEngine.Initialize.
4 tasks
filmor
pushed a commit
to filmor/pythonnet
that referenced
this issue
Oct 29, 2018
…thonEngine.Initialize.
filmor
pushed a commit
to filmor/pythonnet
that referenced
this issue
Nov 13, 2018
…thonEngine.Initialize.
filmor
pushed a commit
to filmor/pythonnet
that referenced
this issue
Nov 15, 2018
…thonEngine.Initialize.
filmor
pushed a commit
to filmor/pythonnet
that referenced
this issue
Nov 15, 2018
…thonEngine.Initialize.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Environment
2.3.0
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Win 7, 64 bit
Details
Console application with CTRL+C handling.
According to https://docs.python.org/2/c-api/init.html, Py_Initialize() changes the current signal configuration. In practice, signals like interrupt from CTRL+C in a console application seems to be ignored, which is not the desired behavior. This means that the event handler configured as this
Console.CancelKeyPress += Console_CancelKeyPress;
does nothing.It seems Py_InitializeEx(0) should be used for general applications that does not include a python terminal. Alternatively, whether to use the Py_InitalizeEx(0) could be a argument to Python.Initialize()
To reproduce try running this:
The text was updated successfully, but these errors were encountered: