Skip to content

Commit

Permalink
watchdog==4.0.0 (Chia-Network#17666)
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky authored Mar 7, 2024
1 parent f81e867 commit 57193ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions chia/util/file_keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing_extensions import final
from watchdog.events import DirModifiedEvent, FileSystemEvent, FileSystemEventHandler
from watchdog.observers import Observer
from watchdog.observers.api import BaseObserver

from chia.util.default_root import DEFAULT_KEYS_ROOT_PATH
from chia.util.errors import KeychainFingerprintNotFound, KeychainLabelExists, KeychainLabelInvalid
Expand Down Expand Up @@ -171,7 +172,7 @@ def to_dict(self) -> Dict[str, Any]:

@final
@dataclass
class FileKeyring(FileSystemEventHandler): # type: ignore[misc] # Class cannot subclass "" (has type "Any")
class FileKeyring(FileSystemEventHandler):
"""
FileKeyring provides a file-based keyring store to manage a FileKeyringContent .The public interface is intended
to align with the API provided by the keyring module such that the KeyringWrapper class can pick an appropriate
Expand All @@ -181,7 +182,7 @@ class FileKeyring(FileSystemEventHandler): # type: ignore[misc] # Class cannot
keyring_path: Path
# Cache of the whole plaintext YAML file contents (never encrypted)
cached_file_content: FileKeyringContent
keyring_observer: Observer = field(default_factory=Observer)
keyring_observer: BaseObserver = field(default_factory=Observer)
load_keyring_lock: threading.RLock = field(default_factory=threading.RLock) # Guards access to needs_load_keyring
needs_load_keyring: bool = False
# Cache of the decrypted YAML contained in keyring.data
Expand Down Expand Up @@ -227,12 +228,16 @@ def lock_and_reload_if_required(self) -> Iterator[None]:
def setup_keyring_file_watcher(self) -> None:
# recursive=True necessary for macOS support
if not self.keyring_observer.is_alive():
self.keyring_observer.schedule(self, self.keyring_path.parent, recursive=True)
self.keyring_observer.start()
self.keyring_observer.schedule( # type: ignore[no-untyped-call]
self,
self.keyring_path.parent,
recursive=True,
)
self.keyring_observer.start() # type: ignore[no-untyped-call]

def cleanup_keyring_file_watcher(self) -> None:
if self.keyring_observer.is_alive():
self.keyring_observer.stop()
self.keyring_observer.stop() # type: ignore[no-untyped-call]
self.keyring_observer.join()

def on_modified(self, event: Union[FileSystemEvent, DirModifiedEvent]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"sortedcontainers==2.4.0", # For maintaining sorted mempools
"click==8.1.3", # For the CLI
"dnspython==2.5.0", # Query DNS seeds
"watchdog==2.2.0", # Filesystem event watching - watches keyring.yaml
"watchdog==4.0.0", # Filesystem event watching - watches keyring.yaml
"dnslib==0.9.24", # dns lib
"typing-extensions==4.10.0", # typing backports like Protocol and TypedDict
"zstd==1.5.5.1",
Expand Down

0 comments on commit 57193ae

Please sign in to comment.