From 81da2df0c099e1bb875fd1231b977c71a2c5ec0f Mon Sep 17 00:00:00 2001 From: Filip Cacky Date: Tue, 22 Oct 2024 16:11:25 +0200 Subject: [PATCH] Fix signal manager class vars --- metaflow/runner/signal_manager.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/metaflow/runner/signal_manager.py b/metaflow/runner/signal_manager.py index 8f177e52609..2b849dd796c 100644 --- a/metaflow/runner/signal_manager.py +++ b/metaflow/runner/signal_manager.py @@ -1,6 +1,6 @@ import asyncio import signal -from typing import NewType, Mapping, Set, Callable, Optional +from typing import NewType, MutableMapping, Set, Callable, Optional SignalHandler = NewType("SignalHandler", Callable[[int, []], None]) @@ -27,8 +27,8 @@ class SignalManager: hook_signals: bool event_loop: Optional[asyncio.AbstractEventLoop] - signal_map: Mapping[int, Set[SignalHandler]] = dict() - replaced_signals: Mapping[int, SignalHandler] = dict() + signal_map: MutableMapping[int, Set[SignalHandler]] + replaced_signals: MutableMapping[int, SignalHandler] def __init__( self, @@ -41,6 +41,9 @@ def __init__( except RuntimeError: self.event_loop = None + self.signal_map = {} + self.replaced_signals = {} + def __exit__(self, exc_type, exc_value, traceback): for sig in self.signal_map: self._maybe_remove_signal_handler(sig)