Linux filesystem directory monitoring using inotify
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Treewatcher is a python library to monitor a directory recursively using inotify. The user can define callbacks by subclassing a class. Depending from the type of the class the user subclass from, callbacks can be executed in the same process of the monitoring process, in a thread or a pool of thread.

Treewatcher is still a work in progress and the main focus for now is automated testing.

It's inspired from some parts of the pytagsfs project :


inotifyx (>=0.1.1) : You can install it using pip: $ pip install inotifyx

You can also run python install from the project root directory, it will pull the needed dependencies.


I suggest to use virtualenv. It will help keeping your distribution happy :) Install inotifyx (see Dependencies) and install treewatcher :

$ git clone git://
$ cd treewatcher && python install

Here is a complete example using virtualenv and virtualenvwrapper from

$ mkvirtualenv test
$ easy_install pip
$ git clone git://
$ cd treewatcher
$ python install

You're done ! You can now launch the test suite :

$ cd tests && ./

Launching tests

Tests are in the 'tests' directory. They can all be launch using the script :

$ ./ (it takes 10 minutes on my machine)

You can also list all available test using le -l option :

$ ./ -l

You can pick one, or more from the list and run them :

$ ./ TestSerialTreeWatcher.test_nosublevel_onefile TestFourThreadsTreeWatcher.test_one_sublevel_one

You can also run each test files individually :

$ python

You can list tests available from a specific file :

$ python -l

And run specifics tests from a specific file :

$ python TestSerialTreeWatcher.test_nosublevel_onedir  TestSerialTreeWatcher.test_nosublevel_onefile


You will find examples in the examples directory.

How does it work ?

Events Process (Producer) ------> Events Queue ------> Events Dispatcher (serial, threaded, processes) ------> Event consumer