Skip to content
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

Register existing signal handlers in simpervisor's atexit module #39

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mahendrapaipuri
Copy link

@mahendrapaipuri mahendrapaipuri commented Jun 27, 2023

Effectively, we are checking if the existing handlers are different from the default ones and if they are not default, we execute these handlers in the signal handler. I am not sure if it is the most elegant solution but happy to get any insights!!

Fixes #38

Ensure that we do not override the existing signal handlers registered
in Python
@welcome
Copy link

welcome bot commented Jun 27, 2023

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

mahendrapaipuri and others added 3 commits June 28, 2023 12:01
We check if the existing handlers for SIGINT and SIGTERM are different
from default handlers.

Only when they are custom handlers, we execute them in our custom
handler
@consideRatio consideRatio force-pushed the fix_signal_handler_overrides branch 2 times, most recently from 826a14b to b21f08d Compare January 30, 2024 11:44
@consideRatio
Copy link
Member

Thank you for working this @mahendrapaipuri and sorry for the slow turnaround of review. I'm not confident this is right yet.

I pushed few commits, but is this working correctly etc? I've not added a test, which i think would be good to have. I also don't feel confident on the windows parts here.

@consideRatio consideRatio added the enhancement New feature or request label Jan 30, 2024
Comment on lines +70 to +74
# call previously registered non-default Python callable handler or exit
if prev_handler:
prev_handler(signum, *args)
Copy link
Member

Choose a reason for hiding this comment

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

Should get review and ideally tested on windows:

  • I made this prev_handler(signum, *args) instead of prev_handler(signum, None)`, is this right?

Copy link
Author

Choose a reason for hiding this comment

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

*args will be frame argument. Not sure if it works on windows though. I think we can pass *args to handler.

I'm not confident this is right, but not confident on the passing None
either. What is correct here?
@consideRatio consideRatio force-pushed the fix_signal_handler_overrides branch 2 times, most recently from 80d7579 to 4d2e774 Compare January 30, 2024 14:10
Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

I think this may be ok to merge now, but I'm not sure. What makes it complicated is the windows parts mostly. I don't get the windows situation =/

@manics
Copy link
Member

manics commented Jan 30, 2024

I've got access to a Windows VM with conda. It's not clear how to test this specific functionality though.

@mahendrapaipuri
Copy link
Author

@consideRatio Thanks a lot for looking into this PR. I still need to look into changes you have pushed. I dont have a lot of experience with windows and neither I have access to windows machine to test it.

@manics If you have access to windows machine, we can test this as described in the issue. Do you think it is doable?

consideRatio and others added 3 commits January 30, 2024 17:27
* Test will check if registered non default handlers are called

* Cast port number to int in simplehttpserver.py script

Signed-off-by: Mahendra Paipuri <[email protected]>
@mahendrapaipuri
Copy link
Author

@consideRatio @manics I have pushed a unit test to check if we are calling existing non default handlers. Please have a look at it when you can. Not sure if we can test this functionality on windows easily though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simpervisor overrides the existing signal handlers
4 participants