asynchronous watchdog
Project description
wcpan.watchdog
An asynchronous watchdog utility built with asyncio.
Installation
pip install wcpan.watchdog
Command Line Usage
You can simply use the main module like this:
python3 -m wcpan.watchdog -- <any command>
It will restart the command (if it is still running) for every file changed.
Library Usage
You can also use this in your code:
import asyncio
import signal
from wcpan.watchdog.watcher import Watcher
async def auto_rerun():
path = 'the path you want to observe'
# Setup how to stop the watcher.
# In this example I use SIGINT to set the Event.
loop = asyncio.get_running_loop()
stop_event = asyncio.Event()
loop.add_signal_handler(signal.SIGINT, lambda: stop_event.set())
async with Watcher() as watcher:
# This will not stop until stop_event is set.
async for changes in watcher(path, stop_event=stop_event):
# Changes contains changed information.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wcpan.watchdog-1.1.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for wcpan.watchdog-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f8c8bc563750021b71b4f4c68a8f52e1829b58757b7d96d0aa3cdade84628ef |
|
MD5 | 418a3acb3f1b9595b3645d12e0c2481f |
|
BLAKE2b-256 | a3e75e44bd030be0ff4b5fba6448817fb0c5259d0320f226ffd178715c3053cd |