This is a strange one and strace is not giving me any useful information. I am using pyinotify 0.9.6 to watch a directory recursively so I can commit changes about it to a MySQL database. The problem is when I have pyinotify running (daemonized or not), i can remove files in the sub-directories but not the sub-directories themselves. rmdir exits with status 0 and everything looks right on the system level, but the sub directory is still there just chilling. I may just be being stupid as I am new to the framework, but here is an example of how I am initializing the watch:
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm)
wm.add_watch('/path/to/dir', pyinotify.IN_CLOSE_WRITE, rec=True, auto_add=True,\
proc_fun=CommitFunction() # I can supply this if you think it's relevant
notifier.loop(daemonize=True, callback=None,\
stdout='/path/to/log.log, stderr='/path/to/log.log')
So in this example if there was a file '/path/to/dir/file.txt' I could run a rm on 'file.txt' and it gets deleted, but if there was a sub-directory '/path/to/dir/subdir' running rm -r on 'subdir' exits cleanly but the directory doesn't actually get deleted.
Furthermore my logs aren't getting written, but I am pretty sure that's my fault somewhere.
EDIT:
Here is an example CommitFunction:
class CommitFunction(pyinotify.ProcessEvent):
def process_default(self, event):
dir = event.path
file = event.name
print "%s is the new file" % os.path.join(dir, file)
EDIT2: Actually my logs probably aren't getting written because I don't call a log or print function anywhere during the commit. I just write straight to my MySQL database
EDIT3: Ok here goes. Hopefully I am not delving too deep. Here is what I try on the command line:
bash$ cd /var/www
bash$ mkdir subdir
bash$ rmdir subdir
bash$ ls
subdir
Here is the actual commit function:
class CommitFunction(pyinotify.ProcessEvent):
def process_default(self, event):
dir = event.path
file = event.name
dbaccess.commit(dir, file) # dir corresponds to a project name
I can keep going deeper if you want, but dbaccess has all my functions for committing and querying the database (nothing really touching the fs) and it further draws from a 'models' file that defines my tables. It's a flask/uwsgi app if that helps at all