changer le look du calendar légèrement et régler problème avec déconnection des test
CI - Security, Lint & Tests / validate (push) Canceled after 0s
CI - Security, Lint & Tests / validate (push) Canceled after 0s
This commit is contained in:
+18
-4
@@ -324,8 +324,9 @@ def _create_database():
|
||||
def _stop(*_args):
|
||||
"""Stop the PostgreSQL server with a fast shutdown.
|
||||
|
||||
Registered as ``atexit`` and signal handler so it fires on Ctrl+C,
|
||||
normal exit, and terminal close.
|
||||
Registered as an ``atexit`` handler so it fires on normal exit. Signal
|
||||
handling goes through ``_handle_stop_signal``, which also stops the
|
||||
server but then re-raises so the process actually exits.
|
||||
"""
|
||||
global _started
|
||||
global _stopped_system_service_name
|
||||
@@ -349,6 +350,19 @@ def _stop(*_args):
|
||||
_start_system_service(srv)
|
||||
|
||||
|
||||
def _handle_stop_signal(signum, frame):
|
||||
"""Stop PostgreSQL, then let the interpreter shut down normally.
|
||||
|
||||
``_stop`` alone would swallow Ctrl+C: it stops the server and restores the
|
||||
system service, then returns without exiting, leaving the dev server
|
||||
running against a stopped database and the terminal frozen. Re-raising
|
||||
``KeyboardInterrupt`` hands control back to the framework, which exits;
|
||||
the ``atexit`` registration then runs ``_stop`` again (idempotent).
|
||||
"""
|
||||
_stop()
|
||||
raise KeyboardInterrupt
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -420,9 +434,9 @@ def start() -> str:
|
||||
_started = True
|
||||
atexit.register(_stop)
|
||||
with contextlib.suppress(ValueError, OSError):
|
||||
signal.signal(signal.SIGINT, _stop)
|
||||
signal.signal(signal.SIGINT, _handle_stop_signal)
|
||||
with contextlib.suppress(AttributeError, ValueError, OSError):
|
||||
signal.signal(signal.SIGBREAK, _stop) # type: ignore[attr-defined]
|
||||
signal.signal(signal.SIGBREAK, _handle_stop_signal) # type: ignore[attr-defined]
|
||||
|
||||
logger.info('Local PostgreSQL ready — DATABASE_URL=%s', DATABASE_URL)
|
||||
return DATABASE_URL
|
||||
|
||||
Reference in New Issue
Block a user