first commit
This commit is contained in:
26
app/worker.py
Normal file
26
app/worker.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import signal
|
||||
import time
|
||||
|
||||
from .config import Config
|
||||
from .queue import migration_queue
|
||||
|
||||
|
||||
def main():
|
||||
"""Запуск отдельного worker-процесса очереди и расписаний."""
|
||||
stop_requested = False
|
||||
|
||||
def request_stop(_signum, _frame):
|
||||
nonlocal stop_requested
|
||||
stop_requested = True
|
||||
|
||||
signal.signal(signal.SIGINT, request_stop)
|
||||
signal.signal(signal.SIGTERM, request_stop)
|
||||
|
||||
migration_queue.start()
|
||||
|
||||
while not stop_requested:
|
||||
time.sleep(max(Config.QUEUE_POLL_SECONDS, 1.0))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user