pyneric.fsnotify

The pyneric.fsnotify module contains file system notification helpers.

Use of this module requires the pyinotify library.

class pyneric.fsnotify.FileSystemNotifier(queue)[source]

Bases: object

Notify the caller of file system changes via a queue using pyinotify.

Events from the pyinotify library are put onto the queue according to the watches the caller configures in watch_manager. The notifier needs to be started via start() to get the events. The notifier needs to be stopped via stop() when the caller would like to stop the events or delete the notifier.

Note that the inotify polling occurs in a separate thread, and one such thread is created for each FileSystemNotifier instance, so if it is feasible, sharing a notifier/queue is recommended for multiple watches.

notifier

A pyinotify.ThreadedNotifier instance that is a Python Thread that watches the file system for events configured in watch_manager. Those events are put on the queue as they occur.

queue

A Python queue.Queue instance (or Queue.Queue in Python 2) that is provided to the constructor.

watch_manager

A pyinotify.WatchManager instance that provides management for which events to watch on which files and directories.

start()

See threading.Thread.start().

stop()

See pyinotify.ThreadedNotifier.stop().

All other methods are passed through to watch_manager. See pyinotify.WatchManager.