Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Mar 31, 2024
1 parent d1cd613 commit 7ebb056
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions metronomes/metronome.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Union, Optional, Any
from typing import Type, Callable, Union, Optional, Any
from threading import Thread, Lock
from time import perf_counter, sleep

Expand All @@ -11,7 +11,7 @@


class Metronome:
def __init__(self, duration: Union[int, float], callback: Callable[[], Any], suppress_exceptions: bool = True, logger: LoggerProtocol = EmptyLogger(), cancellation_token: Optional[AbstractToken] = None) -> None:
def __init__(self, duration: Union[int, float], callback: Callable[[], Any], suppress_exceptions: bool = True, logger: LoggerProtocol = EmptyLogger(), cancellation_token: Optional[AbstractToken] = None, lock_factory: Union[Type[ContextLockProtocol], Callable[[], ContextLockProtocol]] = Lock) -> None:
if duration <= 0:
raise ValueError('The duration of the metronome iteration (tick-tock time) must be greater than zero.')

Expand All @@ -23,7 +23,7 @@ def __init__(self, duration: Union[int, float], callback: Callable[[], Any], sup
self.thread: Optional[Thread] = None
self.started: bool = False
self.stopped: bool = False
self.lock: ContextLockProtocol = Lock()
self.lock: ContextLockProtocol = lock_factory()

def start(self) -> None:
with self.lock:
Expand Down

0 comments on commit 7ebb056

Please sign in to comment.