Skip to main content

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.3.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

wcpan_watchdog-1.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file wcpan_watchdog-1.3.1.tar.gz.

File metadata

  • Download URL: wcpan_watchdog-1.3.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for wcpan_watchdog-1.3.1.tar.gz
Algorithm Hash digest
SHA256 a5e0da3c939632e76b69eb2f5189d9bb1aeaea553aca67ecbe02e2ae865ff200
MD5 4ca725371a7ef6cc61830256da5f72b1
BLAKE2b-256 1bf7ac98d10db54387b8b7936ba58d2fb92976e467d6a9b5613c7c600ca1fdb5

See more details on using hashes here.

File details

Details for the file wcpan_watchdog-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: wcpan_watchdog-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for wcpan_watchdog-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1310e7af2608e727799a0528530519832b506269e1cc91a22ec512d08d90ba40
MD5 4434c2e9c140273385f561866fbb6719
BLAKE2b-256 6fcededa93dfc68b5d027427d6b2e3ad60c34e888df179757da99d1e423c01ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page