Skip to main content

Simple inotify

Very thin inotify(7) wrapper for Linux.

  • Pure Python, depends on ctypes in standard library, no other dependencies
  • Simply group and expose the underlying syscall, Linux specific
  • Only simple event parsing, no complex event model or worker thread
  • No recursive watching support, the same as the underlying syscall
  • Supports non-blocking mode and get the fd, to be polled in your event loop

Example

from simple_inotify import *

observer = Inotify()
wd = ovserver.add_watch("/tmp")
while True:
	events = observer.read()
	for ev in events:
		print(ev)

API reference

The import module name is simple_inotify

Please refer to inotify(7) for details

inotify_event

inotify_event = namedtuple("inotify_event", ("wd", "mask", "cookie", "len", "name"))

class Inotify

Inotify class thar wraps inotify functions.

init(self, flags = 0)

Initializer, calling inotify_init1(2) with flags and holds the returned fd. Available flags are IN_CLOEXEC and IN_NONBLOCK.

close(self)

Calling close(2) on the inotify fd.

fileno(self)

Gets the underlying inotify fd, could be used to poll(2) elsewhere.

add_watch(self, path, /, mask = IN_ALL_EVENTS)

Calling inotify_add_watch(2) to register a new watch item, returns the watch descriptor.

rm_watch(self, wd)

Calling inotify_rm_watch(2) with given wd to unregister a watch.

get(self, wd)

Gets the path used to register the watch wd, returns None if not known.

read(self)

Calling read(2) on the inotify fd and parse the results. Returns a list of inotify_event. If the IN_NONBLOCK flag is set, returns an empty list if there is no new data.

constants

  • IN_ACCESS
  • IN_MODIFY
  • IN_ATTRIB
  • IN_CLOSE_WRITE
  • IN_CLOSE_NOWRITE
  • IN_OPEN
  • IN_MOVED_FROM
  • IN_MOVED_TO
  • IN_CREATE
  • IN_DELETE
  • IN_DELETE_SELF
  • IN_MOVE_SELF
  • IN_UNMOUNT
  • IN_Q_OVERFLOW
  • IN_IGNORED
  • IN_CLOSE
  • IN_MOVE
  • IN_ONLYDIR
  • IN_DONT_FOLLOW
  • IN_EXCL_UNLINK
  • IN_MASK_CREATE
  • IN_MASK_ADD
  • IN_ISDIR
  • IN_ONESHOT
  • IN_ALL_EVENTS
  • IN_CLOEXEC
  • IN_NONBLOCK

Reference

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_inotify-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_inotify-0.0.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file simple_inotify-0.0.1.tar.gz.

File metadata

  • Download URL: simple_inotify-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simple_inotify-0.0.1.tar.gz
Algorithm Hash digest
SHA256 db44e3ae7b90ecc86d600e9e28c0bde4d17a7b38fc4b058367c712fc918ab75b
MD5 2b635248c4b5a857f86c8ccbb324dea8
BLAKE2b-256 8f8be53af0cc0b72f2c226cc9dd80d44b9325713632e9da43f0fe04fdfc8be34

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_inotify-0.0.1.tar.gz:

Publisher: python-publish.yml on USN484259/simple-inotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_inotify-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: simple_inotify-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simple_inotify-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 949dc94337394d153b0f6e34e9269bfbcfb8152087872db03be8d62263a0673a
MD5 6cf36860e4e1bf3532138a7ad4aa1090
BLAKE2b-256 e54482f910e0d0737ce6ef78141e6b3186f18e2afc418a1c2c8c463854bf3531

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_inotify-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on USN484259/simple-inotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 files

Supported by

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