The remi package is replacing SIGINT handlers in the process and causing the signal to be ignored:
def serve_forever(self):
# we could join on the threads, but join blocks all interrupts (including
# ctrl+c, so just spin here
# noinspection PyBroadException
try:
def sig_manager(sig, callstack):
self.stop()
self._log.info('*** signal %d received.' % sig)
return signal.SIG_IGN
prev_handler = signal.signal(signal.SIGINT, sig_manager)
except Exception:
# signal.pause() is missing for Windows; wait 1ms and loop instead
pass
except KeyboardInterrupt:
pass
(source: remi/server.py)
An application running multiple threads is thus unable to stop gracefully.
The remi package (__init__.py) even imports a special function for starting the server:
from .server import App, Server, start
But there is no interface for stopping it. Why?
I've found this old bug report where a functional solution was proposed but the report was closed for no reason: #274 (comment)
So, if one has an instance of such a MyApp, they can do this:
my_app = MyApp()
def interrupt_handler():
my_app_instance.server.server_starter_instance._alive = False
my_app_instance.server.server_starter_instance._sserver.shutdown()
return signal.SIG_DFL
remi.start(my_app, ...)
signal.signal(signal.SIGINT, interrupt_handler)
or they have to implement such a handler into their MyApp.
The remi package is replacing SIGINT handlers in the process and causing the signal to be ignored:
(source:
remi/server.py)An application running multiple threads is thus unable to stop gracefully.
The remi package (
__init__.py) even imports a special function for starting the server:But there is no interface for stopping it. Why?
I've found this old bug report where a functional solution was proposed but the report was closed for no reason: #274 (comment)
So, if one has an instance of such a
MyApp, they can do this:or they have to implement such a handler into their
MyApp.