7

I would like Pyinotify to watch a templates directory, which has subfolders, but I'm getting this error:

DIRECTORY /home/project/templates
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates WD=-1
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates/dir1 WD=-1
[Pyinotify ERROR] add_watch: cannot watch /home/project/templates/dir2 WD=-1
Waiting for stuff to happen...

I've found answers such as using a unicode directory name or using other programs which use inotify, but each is too specific.

What generally causes this error?

Matt Norris
  • 8,596
  • 14
  • 59
  • 90
  • https://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached/13757#13757 Possibly the best answer I have found. – Vaibhav Mishra Jul 23 '20 at 16:57

1 Answers1

14

Increase the maximum number or watches:

sudo sysctl -n -w fs.inotify.max_user_watches=16384

Reference: http://github.com/seb-m/pyinotify/wiki/Frequently-Asked-Questions

ASIDE

If you're looking for notification tools, also try http://github.com/peterbe/python-gorun.

Matt Norris
  • 8,596
  • 14
  • 59
  • 90