From a0cf043c417928c200d253a615fd8b695a880e84 Mon Sep 17 00:00:00 2001 From: Gabriele-V Date: Sat, 13 Dec 2025 20:24:06 +0100 Subject: [PATCH 1/4] Replace os.uname()[1] with socket.gethostname() for Windows compatibility --- scheduler/worker/worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduler/worker/worker.py b/scheduler/worker/worker.py index b664ce6..d1d3f56 100644 --- a/scheduler/worker/worker.py +++ b/scheduler/worker/worker.py @@ -839,7 +839,7 @@ def _ensure_list(obj: Any) -> List[Any]: def _calc_worker_name(existing_worker_names: Collection[str]) -> str: - hostname = os.uname()[1] + hostname=socket.gethostname() c = 1 worker_name = f"{hostname}-worker.{c}" while worker_name in existing_worker_names: From d26789c997c7926aa41881148088c08c5f0c07d6 Mon Sep 17 00:00:00 2001 From: Gabriele-V Date: Sat, 13 Dec 2025 20:25:25 +0100 Subject: [PATCH 2/4] fork job only if supported by OS --- scheduler/worker/worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduler/worker/worker.py b/scheduler/worker/worker.py index d1d3f56..5a673d2 100644 --- a/scheduler/worker/worker.py +++ b/scheduler/worker/worker.py @@ -649,7 +649,7 @@ def execute_job(self, job: JobModel, queue: Queue) -> None: The worker will wait for the job execution process and make sure it executes within the given timeout bounds, or will end the job execution process with SIGALRM. """ - if self.fork_job_execution: + if hasattr(os, "fork") and self.fork_job_execution: self._model.set_field("state", WorkerStatus.BUSY, connection=self.connection) self.fork_job_execution_process(job, queue) self.monitor_job_execution_process(job, queue) From 00cfe1c476abef8e4fcc2282db55f5adeb68b444 Mon Sep 17 00:00:00 2001 From: Gabriele-V Date: Sat, 13 Dec 2025 20:28:58 +0100 Subject: [PATCH 3/4] Return the appropriate death penalty class based on platform --- scheduler/helpers/timeouts.py | 8 ++++++++ scheduler/types/settings_types.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scheduler/helpers/timeouts.py b/scheduler/helpers/timeouts.py index 298ceb6..09e8fb5 100644 --- a/scheduler/helpers/timeouts.py +++ b/scheduler/helpers/timeouts.py @@ -121,3 +121,11 @@ def cancel_death_penalty(self): return self._timer.cancel() self._timer = None + + +def get_default_death_penalty_class() -> type[BaseDeathPenalty]: + """Returns the default death penalty class based on the platform.""" + if hasattr(signal, 'SIGALRM'): + return UnixSignalDeathPenalty + else: + return TimerDeathPenalty \ No newline at end of file diff --git a/scheduler/types/settings_types.py b/scheduler/types/settings_types.py index 3ec1478..0e1e3ed 100644 --- a/scheduler/types/settings_types.py +++ b/scheduler/types/settings_types.py @@ -3,7 +3,7 @@ from enum import Enum from typing import Callable, Dict, Optional, List, Tuple, Any, Type, ClassVar, Set -from scheduler.helpers.timeouts import BaseDeathPenalty, UnixSignalDeathPenalty +from scheduler.helpers.timeouts import BaseDeathPenalty, get_default_death_penalty_class if sys.version_info >= (3, 11): from typing import Self @@ -40,7 +40,7 @@ class SchedulerConfiguration: DEFAULT_MAINTENANCE_TASK_INTERVAL: int = 10 * 60 # The interval to run maintenance tasks in seconds. 10 minutes. DEFAULT_JOB_MONITORING_INTERVAL: int = 30 # The interval to monitor jobs in seconds. SCHEDULER_FALLBACK_PERIOD_SECS: int = 120 # Period (secs) to wait before requiring to reacquire locks - DEATH_PENALTY_CLASS: Type[BaseDeathPenalty] = UnixSignalDeathPenalty + DEATH_PENALTY_CLASS: Type[BaseDeathPenalty] = get_default_death_penalty_class() @dataclass(slots=True, frozen=True, kw_only=True) From 1d9ca8b2be48ee0d5e3637a839cbe4ff0cd273d1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Dec 2025 19:31:58 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scheduler/helpers/timeouts.py | 4 ++-- scheduler/worker/worker.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scheduler/helpers/timeouts.py b/scheduler/helpers/timeouts.py index 09e8fb5..76dcedc 100644 --- a/scheduler/helpers/timeouts.py +++ b/scheduler/helpers/timeouts.py @@ -125,7 +125,7 @@ def cancel_death_penalty(self): def get_default_death_penalty_class() -> type[BaseDeathPenalty]: """Returns the default death penalty class based on the platform.""" - if hasattr(signal, 'SIGALRM'): + if hasattr(signal, "SIGALRM"): return UnixSignalDeathPenalty else: - return TimerDeathPenalty \ No newline at end of file + return TimerDeathPenalty diff --git a/scheduler/worker/worker.py b/scheduler/worker/worker.py index 5a673d2..1ee0fcc 100644 --- a/scheduler/worker/worker.py +++ b/scheduler/worker/worker.py @@ -839,7 +839,7 @@ def _ensure_list(obj: Any) -> List[Any]: def _calc_worker_name(existing_worker_names: Collection[str]) -> str: - hostname=socket.gethostname() + hostname = socket.gethostname() c = 1 worker_name = f"{hostname}-worker.{c}" while worker_name in existing_worker_names: