Skip to content

Commit

Permalink
remove generic alltogether from SignalService, typing memes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshardmind committed Dec 17, 2024
1 parent b554e94 commit cc590ab
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/async_utils/sig_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
type HandleableSignals = Literal["SIGINT", "SIGTERM", "SIGBREAK", "SIGHUP"]
type SignalTuple = tuple[HandleableSignals, ...]


type _DEF = tuple[Literal["SIGINT"], Literal["SIGTERM"], Literal["SIGBREAK"]]
default_handled: Final[_DEF] = "SIGINT", "SIGTERM", "SIGBREAK"
default_handled: Final = "SIGINT", "SIGTERM", "SIGBREAK"


class SpecialExit(enum.IntEnum):
Expand All @@ -44,15 +42,15 @@ class SpecialExit(enum.IntEnum):
EXIT = 252


class SignalService[T: SignalTuple]:
class SignalService:
"""Helper for signal handling.
Meant for graceful signal handling where the main thread is only used
for signal handling.
This should be paired with event loops being run in threads.
"""

def __init__(self, signals: T = default_handled, /) -> None:
def __init__(self, signals: SignalTuple = default_handled, /) -> None:
self._startup: list[StartStopCall] = []
self._cbs: list[SignalCallback] = []
self._joins: list[StartStopCall] = []
Expand Down

0 comments on commit cc590ab

Please sign in to comment.