import os, fcntl, signal
dirlist = []
+active = False
+again = False
def notified(sig, stack):
- for d in dirlist:
- fcntl.fcntl(d.fd, fcntl.F_NOTIFY, (fcntl.DN_MODIFY|fcntl.DN_RENAME|
- fcntl.DN_CREATE|fcntl.DN_DELETE))
- d.check()
+ global active, again
+ if active:
+ again = True
+ return
+ again = True
+ while again:
+ active = True
+ again = False
+ for d in dirlist:
+ fcntl.fcntl(d.fd, fcntl.F_NOTIFY, (fcntl.DN_MODIFY|fcntl.DN_RENAME|
+ fcntl.DN_CREATE|fcntl.DN_DELETE))
+ d.check()
+ active = False
class dir():
def __init__(self, dname):
def watch(self, fname, callback):
f = file(os.path.join(self.dname, fname), callback)
self.files.append(f)
+ f.check()
return f
def watchall(self, callback):