Skip to main content

Hachiko

CI PyPI

An extremely simple asyncio-based wrapper around Watchdog.

pip install hachiko

Hachiko supports Python 3.6 and newer, and watchdog 2.1.6 and newer (including watchdog 7). CI tests that whole range.

Example usage

You need to subclass AIOEventHandler and either:

  1. Use it directly with a Watchdog Observer object, or;
  2. Pass it to AIOWatchdog and use it there.
import asyncio

from hachiko import AIOEventHandler, AIOWatchdog

WATCH_DIRECTORY = "/path/to/watch/directory/"


class MyEventHandler(AIOEventHandler):
    """Subclass of asyncio-compatible event handler."""

    async def on_created(self, event):
        print("Created:", event.src_path)  # add your functionality here

    async def on_deleted(self, event):
        print("Deleted:", event.src_path)  # add your functionality here

    async def on_moved(self, event):
        print("Moved:", event.src_path, "->", event.dest_path)

    async def on_modified(self, event):
        print("Modified:", event.src_path)  # add your functionality here


async def watch_fs(watch_dir):
    evh = MyEventHandler()  # create handlers inside a running event loop
    watch = AIOWatchdog(watch_dir, event_handler=evh)
    watch.start()
    for _ in range(20):
        await asyncio.sleep(1)
    watch.stop()


asyncio.run(watch_fs(WATCH_DIRECTORY))

On Python 3.6, which has no asyncio.run(), use asyncio.get_event_loop().run_until_complete(watch_fs(WATCH_DIRECTORY)).

Create your handler while the event loop is running (as above), or pass the loop explicitly with MyEventHandler(loop=loop).

Events

Override any of these coroutines. Each receives the watchdog event object.

Handler Called for Notes
on_any_event every event Also called for event types hachiko doesn't know about yet
on_created file or directory created
on_deleted file or directory deleted
on_modified file or directory modified
on_moved file or directory moved/renamed event.dest_path is the new path
on_closed file closed after writing Linux only
on_closed_no_write file closed without writing Linux only, watchdog 5+
on_opened file opened Linux only, watchdog 2.3+
on_attrib metadata changed (permissions, timestamps…) watchdog 7+; older versions report these as on_modified

Watchdog sometimes reports the same change more than once, so handlers should be safe to run repeatedly for the same path.

Metadata

Release files for hachiko 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hachiko 0.5.0
File Size Uploaded Provenance Actions
hachiko-0.5.0.tar.gz 7.2 kB With provenance Details for hachiko-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hachiko 0.5.0
File Interpreter ABI Platform Actions
hachiko-0.5.0-py3-none-any.whl Python 3 none any Details for hachiko-0.5.0-py3-none-any.whl

Total release size: 11.9 kB

Release files / hachiko-0.5.0.tar.gz

Download URL hachiko-0.5.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b4f20a0cbe2bd438c804af07108e322d98434b1bea70b094c74067085b0e45f9
BLAKE2b-256 checksum
How to use checksums
850dd46760be6c97617d5a3cdf3f99e595bc88d8a0835247d9b9d26831ffa146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / hachiko-0.5.0-py3-none-any.whl

Download URL hachiko-0.5.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57e359eacfcd596ed737be666ff41ba75b6e3338fd93350735ef4b594b59f904
BLAKE2b-256 checksum
How to use checksums
018fdad6ce48e22d945e740ca70c7b34c73c49df57c51f420dbcb0697457c4b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for hachiko 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hachiko-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page