-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add to docs about the fallback PollingObserver
- Loading branch information
Showing
3 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Watchdog testing script from the PyPI page (https://pypi.org/project/watchdog/), | ||
except using a PollingObserver instead of the default | ||
""" | ||
|
||
import sys | ||
import time | ||
import logging | ||
from watchdog.observers.polling import PollingObserver | ||
from watchdog.events import LoggingEventHandler | ||
|
||
if __name__ == "__main__": | ||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="%(asctime)s - %(message)s", | ||
datefmt="%Y-%m-%d %H:%M:%S", | ||
) | ||
path = sys.argv[1] if len(sys.argv) > 1 else "." | ||
event_handler = LoggingEventHandler() | ||
observer = PollingObserver() | ||
observer.schedule(event_handler, path, recursive=True) | ||
observer.start() | ||
try: | ||
while True: | ||
time.sleep(1) | ||
finally: | ||
observer.stop() | ||
observer.join() |