Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WIP: 449 Py_Initialize_SignalConfiguration #450

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
wants to merge 9 commits into from
Closed

WIP: 449 Py_Initialize_SignalConfiguration #450

wants to merge 9 commits into from

Conversation

rmadsen-ks
Copy link
Contributor

@rmadsen-ks rmadsen-ks commented Apr 5, 2017

Note: This PR is not ready yet. I just added the PR to see if it builds.

What does this implement/fix? Explain your changes.

Avoiding overriding signals from the application so that CTRL-C might be handled.

Using Py_InitializeEx(0) (instead Py_Initialize) to avoid overriding signals.

Does this close any currently open issues?

This fixes #449

...

Any other comments?

...

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@mention-bot
Copy link

@rmadsen-ks, thanks! @vmuriart, @davidanthoff, @yagweb, @filmor and @tonyroberts, please review this.

@codecov
Copy link

codecov bot commented Apr 5, 2017

Codecov Report

Merging #450 into master will decrease coverage by 1.08%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #450      +/-   ##
==========================================
- Coverage    77.4%   76.31%   -1.09%     
==========================================
  Files          63       62       -1     
  Lines        5589     5569      -20     
  Branches      892      888       -4     
==========================================
- Hits         4326     4250      -76     
- Misses        970     1026      +56     
  Partials      293      293
Flag Coverage Δ
#setup_linux 63.66% <ø> (-5.76%) ⬇️
#setup_windows 75.66% <66.66%> (-0.92%) ⬇️
Impacted Files Coverage Δ
src/runtime/runtime.cs 90.58% <0%> (-0.79%) ⬇️
src/runtime/pythonengine.cs 77.87% <100%> (-0.45%) ⬇️
src/runtime/constructorbinding.cs 9.85% <0%> (-29.58%) ⬇️
src/runtime/CustomMarshaler.cs 47.94% <0%> (-21.92%) ⬇️
src/runtime/overload.cs 58.33% <0%> (-15.58%) ⬇️
src/runtime/pyiter.cs 63.63% <0%> (-13.64%) ⬇️
src/runtime/iterator.cs 81.81% <0%> (-7.08%) ⬇️
setup.py 83.45% <0%> (-3.96%) ⬇️
src/runtime/pyobject.cs 38.85% <0%> (-0.92%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb84cd2...24ab0d1. Read the comment docs.

/// </remarks>
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true, int initSigs = 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initSigs should be a bool.

@rmadsen-ks
Copy link
Contributor Author

@denfromufa, it seems some of the builds takes an extraordinary amount of time (59 min). Is there some way of canceling the builds so we dont have to wait for timeout?

@den-run-ai
Copy link
Contributor

@rmadsen-ks you may need to have access to CI build servers to cancel the builds, what do you think @vmuriart ?

@den-run-ai
Copy link
Contributor

@rmadsen-ks @filmor @vmuriart do you guys agree on removing the test for this behavior and merge pull request without the tests in CI? We can leave the original issue open, until proper testing is added.

Here is a user in need of this pull request:

#511

@rmadsen-ks
Copy link
Contributor Author

@denfromufa, unfortunately I dont have the bandwidth to figure how to make a unit test that works reliably. It turned out to be harder than expected to signal CTRL+C to an application running in the console on windows. Also I had decided to use CSharpProvider for runtime assembly generation, which I think is not compatible with .NET core, so that will probably need to move to Roslyn.

Do you have another idea of how to test this in an automated way?

In any case, the non-test part I think is low risk, but I suggest you do a bit of manual testing first anyway.

@den-run-ai
Copy link
Contributor

I did not understand the part about CSharpProvider :)

But the Ctrl+c keyboard interrupt can be emulated with this threading call:

thread.interrupt_main() # raises KeyboardInterrupt

More details in this new issue that I linked above.

@rmadsen-ks
Copy link
Contributor Author

@denfromufa, thread.interrupt_main() does not work in our case because we have a C# console application running embedded python code.

This is why I wanted to use CSharpProvider. I wanted to build a short console application that delays for a few s, but is interrupted by a keyboard interrupt. This I could also do by adding an assembly to the git repo, but I figured that would not be a popular decision. In any case, i have not been able to emulate CTRL+C on windows.

In my testing running _thread.interrupt_main() (python 3) as the embedded python script does not have the desired effect.

@filmor filmor self-assigned this Jul 23, 2018
@filmor filmor added this to the 2.4.0 milestone Jul 23, 2018
@filmor
Copy link
Member

filmor commented Aug 30, 2018

Let's continue work on this one in #724.

@filmor filmor closed this Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call to Py_Initialize changes signal handler configuration
4 participants