Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
Merge pull request #2 from pmandrik/FFF_DQMTOOLS_V1
Browse files Browse the repository at this point in the history
Fix inotify WARNING in fff_filemonitor
  • Loading branch information
ahmad3213 authored Jun 21, 2021
2 parents 2bdd472 + 3a60bac commit cc60356
Show file tree
Hide file tree
Showing 11 changed files with 765 additions and 3 deletions.
35 changes: 35 additions & 0 deletions applets/fff_filemonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,42 @@ def process_dir(self):
self.last_scan = time.time()
return False

# watch the directory using inotify 0.2.10
def run_inotify(self):
from gevent import select
import inotify
from inotify import adapters
from inotify import constants

mask = inotify.constants.IN_CLOSE_WRITE | inotify.constants.IN_MOVED_TO
watcher = inotify.adapters.Inotify()
watcher.add_watch(self.path, mask)
fd = watcher._Inotify__inotify_fd

while True:
c = self.process_dir()

# if process_dir return true, we restart this loop
# but we still need to flush watcher (or it will go out of buf)
wait_time = 30
if c:
wait_time = 1

r = select.select([fd], [], [], wait_time)

if len(r[0]) == 0:
# timeout
pass
elif r[0][0] == fd:
# clear the events
for event in watcher.event_gen(0.01, yield_nones=False):
pass
pass
else:
self.log.warning("bad return from select: %s", str(r))

# old version of "watcher" and "inotify" python modules is used here
def run_inotify_old(self):
from gevent import select
import _inotify as inotify
import watcher
Expand Down
1 change: 1 addition & 0 deletions lib/inotify/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.2.10'
Loading

0 comments on commit cc60356

Please sign in to comment.