File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11import asyncio
2+ import signal
3+ import types
4+ import datetime
5+ import sys
26
37from src .job_manager import JobManager
48from src .settings .settings import Settings
812settings = Settings ()
913job_manager = JobManager (settings )
1014
11- # # Main function
15+ def terminate (sigterm : signal .SIGTERM , frame : types .FrameType ) -> None : # noqa: ARG001, pylint: disable=unused-argument
16+
17+ """Terminate cleanly. Needed for respecting 'docker stop'.
18+
19+ Args:
20+ ----
21+ sigterm (signal.Signal): The termination signal.
22+ frame: The execution frame.
23+
24+ """
25+
26+ logger .info (f"Termination signal received at { datetime .datetime .now ()} ." ) # noqa: DTZ005
27+ sys .exit (0 )
28+
29+ # Main function
1230async def main ():
1331 await launch_steps (settings )
1432
@@ -33,4 +51,5 @@ async def main():
3351
3452
3553if __name__ == "__main__" :
54+ signal .signal (signal .SIGTERM , terminate )
3655 asyncio .run (main ())
Original file line number Diff line number Diff line change @@ -47,4 +47,4 @@ async def test_get_handling_method(
4747 result = await handler ._get_handling_method ( # pylint: disable=W0212
4848 "A" , affected_download
4949 )
50- assert result == expected
50+ assert result == expected
You can’t perform that action at this time.
0 commit comments