From 769e5f347cb2b2be8e958e30aa2b53bfe8dcccc5 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Fri, 14 Jun 2024 08:19:08 +0200 Subject: [PATCH] Removed SIGHUP handler on win32. Signed-off-by: Pavel Kirilin --- docs/guide/cli.md | 2 +- taskiq/cli/worker/process_manager.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/guide/cli.md b/docs/guide/cli.md index af40aa7..a8c853f 100644 --- a/docs/guide/cli.md +++ b/docs/guide/cli.md @@ -84,7 +84,7 @@ To enable this option simply pass the `--reload` or `-r` option to worker taskiq Also this option supports `.gitignore` files. If you have such file in your directory, it won't reload worker when you modify ignored files. To disable this functionality pass `--do-not-use-gitignore` option. -### Graceful reload +### Graceful reload (available only on Unix systems) To perform graceful reload, send `SIGHUP` signal to the main worker process. This action will reload all workers with new code. It's useful for deployment that requires zero downtime, but don't use orchestration tools like Kubernetes. diff --git a/taskiq/cli/worker/process_manager.py b/taskiq/cli/worker/process_manager.py index 24f0155..acc3da3 100644 --- a/taskiq/cli/worker/process_manager.py +++ b/taskiq/cli/worker/process_manager.py @@ -1,5 +1,6 @@ import logging import signal +import sys from contextlib import suppress from dataclasses import dataclass from multiprocessing import Event, Process, Queue, current_process @@ -174,10 +175,11 @@ def __init__( shutdown_handler = get_signal_handler(self.action_queue, ShutdownAction()) signal.signal(signal.SIGINT, shutdown_handler) signal.signal(signal.SIGTERM, shutdown_handler) - signal.signal( - signal.SIGHUP, - get_signal_handler(self.action_queue, ReloadAllAction()), - ) + if sys.platform != "win32": + signal.signal( + signal.SIGHUP, + get_signal_handler(self.action_queue, ReloadAllAction()), + ) self.workers: List[Process] = []