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

Why can not reach the harakiri signal handler? #2696

Open
Liubey opened this issue Dec 18, 2024 · 2 comments
Open

Why can not reach the harakiri signal handler? #2696

Liubey opened this issue Dec 18, 2024 · 2 comments

Comments

@Liubey
Copy link

Liubey commented Dec 18, 2024

My config:

harakiri = 10
harakiri-graceful-timeout = 3
harakiri-graceful-signal= 1

the wsgi.py:


def signal_handler(signum, frame):
    print("[Python App] attempting graceful shutdown")



print('try to post form harakiri')
signal.signal(signal.SIGHUP, handler=signal_handler)
print('try to post form harakiri end')

When the project start:
image

When I sleep on api:

image

But , I can not find the handler have already run. I can not find the print log.

Where did I miss?

@Liubey
Copy link
Author

Liubey commented Dec 19, 2024

Use this demo: https://github.com/nzjs/experiments-harakiri/tree/nzjs/update-uwsgi

And also no log when graceful shutdown. I'm running it on my Mac.

What can I do?

INFO 2024-12-19 02:01:12,576 middleware 35705 8449183552 signal handlers: <bound method HarakiriLoggerMiddleware.handle_signal of <class 'harakiri.middleware.HarakiriLoggerMiddleware'>>
INFO 2024-12-19 02:01:12,581 views 35705 8449183552 REQUEST: slow
Thu Dec 19 10:01:17 2024 - *** HARAKIRI ON WORKER 2 (pid: 35705, try: 1, graceful: yes) ***
Thu Dec 19 10:01:17 2024 - HARAKIRI !!! worker 2 status !!!
Thu Dec 19 10:01:17 2024 - HARAKIRI [core 0] 127.0.0.1 - GET /slow/ since 1734573672
Thu Dec 19 10:01:17 2024 - HARAKIRI !!! end of worker 2 status !!!
Thu Dec 19 10:01:17 2024 - HARAKIRI: graceful termination attempt on worker 2 with signal 1. Next harakiri: 1734573680
Thu Dec 19 10:01:17 2024 - HARAKIRI triggered by worker 2 core 0 !!!
Gracefully killing worker 2 (pid: 35705)...
Thu Dec 19 10:01:20 2024 - *** HARAKIRI ON WORKER 2 (pid: 35705, try: 2, graceful: no) ***
Thu Dec 19 10:01:20 2024 - HARAKIRI !!! worker 2 status !!!
Thu Dec 19 10:01:20 2024 - HARAKIRI [core 0] 127.0.0.1 - GET /slow/ since 1734573672
Thu Dec 19 10:01:20 2024 - HARAKIRI !!! end of worker 2 status !!!
Thu Dec 19 10:01:20 2024 - HARAKIRI: graceful termination attempt on worker 2 with signal 1. Next harakiri: 1734573683
Thu Dec 19 10:01:20 2024 - HARAKIRI triggered by worker 2 core 0 !!!

@Liubey
Copy link
Author

Liubey commented Dec 23, 2024

Maybe it depends on Python'version?
On my project, python version=3.7, not work.
On another demo, python version=3.11, It's work.

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

No branches or pull requests

1 participant