squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

japronto catch the SIGINT, how can I register my own signal handler ? #54

Open jiamo opened 7 years ago

jiamo commented 7 years ago

I create an process before create app. When I kil -2 pid. The program got Termination request receive and hangup.

In my create process I also register the handle to SIGINT. When I using ctrl+c the program can exit.

jiamo commented 7 years ago

By the way , I can catch SIGUSR1 to handle this problem . After join my custom process main process, I must using :

def handle_signal(signal, frame):
    print("handle signal_int start\n")
    custom_process.kill()
    custom_porcess.join()
    print("handle end")
    sys.exit()

So In this situation How can I avoid using sys.exit()? Can japronto's workprocess be kill by main process out of the application?

squeaky-pl commented 7 years ago

Currently that's not supported, the best you can do is find relevant piece of code of Application and change it yourself or use monkey patching.

As stated earlier I am working now on inner guts of japronto and won't start adding more user facing APIs until I'm sure that inner design is OK. I will keep this open to add desired funcionality when I am ready.