Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide statistics on how many events were in the queue #190

Open
yellowpattern opened this issue Aug 12, 2020 · 2 comments
Open

Provide statistics on how many events were in the queue #190

yellowpattern opened this issue Aug 12, 2020 · 2 comments

Comments

@yellowpattern
Copy link

The read_events() method interacts with the inotify kernel interface but does not provide any indication of how much was in the queue. It would be useful if read_events() provided a summary of how much was in the queue, how many events and how big the buffer it created from the queue was.

@yellowpattern
Copy link
Author

yellowpattern commented Aug 12, 2020

diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index d2f0816..47e2038 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -1244,6 +1244,7 @@ class Notifier:
             raise NotifierError(msg)
         log.debug('Event queue size: %d', queue_size)
         rsum = 0  # counter
+        events = 0  # counter
         while rsum < queue_size:
             s_size = 16
             # Retrieve wd, mask, cookie and fname_len
@@ -1262,6 +1263,8 @@ class Notifier:
             else:
                 self._eventq.append(rawevent)
             rsum += s_size + fname_len
+            events += 1
+        return [events, rsum, queue_size]

     def process_events(self):
         """
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index bc24313..fd5ea82 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -1227,6 +1227,7 @@ class Notifier:
             raise NotifierError(msg)
         log.debug('Event queue size: %d', queue_size)
         rsum = 0  # counter
+        events = 0  # counter
         while rsum < queue_size:
             s_size = 16
             # Retrieve wd, mask, cookie and fname_len
@@ -1247,6 +1248,8 @@ class Notifier:
             else:
                 self._eventq.append(rawevent)
             rsum += s_size + fname_len
+            events += 1
+        return [events, rsum, queue_size]

     def process_events(self):
         """

inotify.txt

@yellowpattern
Copy link
Author

This also requires a documentation update (ugh!) but adding in returning the array should not impact any existing code - the returned array will just be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant