-
Notifications
You must be signed in to change notification settings - Fork 72
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
Improved single file monitoring. #83
Conversation
inotify/adapters.py
Outdated
@@ -231,6 +231,10 @@ def event_gen( | |||
in self._handle_inotify_event(fd): | |||
last_hit_s = time.time() | |||
|
|||
if handle_in_ignored and\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make it default behavior. The user shouldn't have a choice. Reword the commit message to mention that we're specifically handling the IN_IGNORED event, now.
inotify/adapters.py
Outdated
@@ -115,7 +115,7 @@ def remove_watch(self, path, superficial=False): | |||
|
|||
del self.__watches[path] | |||
|
|||
self.remove_watch_with_id(wd) | |||
self.remove_watch_with_id(wd, superficial) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in a separate commit since it's not related to this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already resolved by #57
This reverts commit 41c19e0.
Hi, I reverted the original commit and did what you asked, but beware, this changes the default behavior of |
… they are removed by the kernel
Hi,
I found that the
Inotify
class is not doing a great job in single file monitoring.According to
man inotify
:The event
IN_IGNORED
is generated when a watch has been automatically removed, this happens when the monitored file is removed, and it also happens when user modify the monitored file with text editors that will replace the original file while saving (such asvim
).But the
Inotify
class itself doesn't handle this event, so the consequence is: when this happens, the watch has been automatically removed by the kernel but it still exists in theInotify
class (inInotify.__watches
andInotify.__watches_r
), and this causes a bug, when a monitored file is removed/replaced, users can no long re-add it back into the monitoring, if they try to remove it first by callingInotify.remove_watch()
then the system callinotify_rm_watch()
will return an error because the watch does not exist in the kernel space.So, the thing I've done is giving users an optional argument to make the
Inotify
class handle theIN_IGNORED
event and it's disabled by default.And I changed the usage of
superficial
parameter inInotify.remove_watch
as well which was not being used.