pyinotify issue

Sebastian "lunar" Wiesner basti.wiesner at
Fri Jun 20 15:09:02 CEST 2008

AndreH <ahaupt at>:

> On Jun 17, 12:11 pm, AndreH <aha... at> wrote:
>> On Jun 13, 3:39 pm, AndreH <aha... at> wrote:
>> > Good day,
>> > I just installed pyinotify on my gentoo box.
>> > When I test the library through "pyinotify.pv -v /tmp" under root,
>> > everything works great, but when I try the same thing under my local
>> > user account, I receive the following error:
>> > Error: cannot watch . (WD=-1)
>> > Not very helpful. I've tried VERBOSE=True mode, but it doens't provide
>> > any additional information.
>> > I also tried it for a directory in my home folder just to be sure it's
>> > not a permission problem, but no luck.
>> > Any ideas?
>> > Regards,
>> > Andre
>> Ok I ended up solving my problem.
>> pyinotify is just a wrapper for the c lib, inotif.h. Installing the
>> inotify-tools package allows one to do better troubleshooting.
>> First, my kernel version was too old and did not allow inotify to be
>> executed at user-level. I bumped my kernel up to 2.6.24 and enabled
>> the user-level execution flag.
>> Then pyinotify worked once and failed for all consecutive retries.
>> inotifwatch said that my "maximum number of user watches" was maxed
>> out and that I should increase it under /proc/sys/fs/inotify/
>> max_user_watches.
>> Something must be wrong, since the max_user_watches was set to 8192. I
>> played around with this setting (sysctl -w
>> fs.inotify.max_user_watches=16843), and inotifywatch, and
>> finally came the conclusion that pyinotify 0.7.0 was buggy. I got hold
>> of 0.7.1 which seems to have fixed this problem. Hopefully, I'm not
>> speaking too soon.
> I spoke too soon.
> pyinotify still seems to max out my number of user watches... I get
> this message when I run inotifywatch after a pyinotify operation:
> Establishing watches...
> Failed to watch .; upper limit on inotify watches reached!
> Please increase the amount of inotify watches allowed per user via `/
> proc/sys/fs/inotify/max_user_watches'.

inotify itself doesn't have support for recursive watches.  If you are
recursively watching a single directory, each subdirectory is added as
single, separate watch.  If you're watching large directories for changes,
it may well be, that there is no bug in inotify, but you're really hitting
the watch limit (which is one of the reasons, why stuff like locate can't
be implemented on top of the inotify mechanism).  Still, it sounds very
unlikely, that there are directories containing more than 8192
sub-directories, but did you consider this?

Freedom is always the freedom of dissenters.
                                      (Rosa Luxemburg)

More information about the Python-list mailing list