Skip to content

Commit

Permalink
Remove Inotify._remove_watch_bookkeeping
Browse files Browse the repository at this point in the history
- The call on inotify_event.is_ignored was removing the wrong wd, due
  to another wd with the same path (self._wd_for_path[src_path] was
  replaced)
- Fix gorakhargosh#117 and gorakhargosh#233
- Still not enough to fix every bug regarding fast/unordered events,
  but doesn't crash anymore
  • Loading branch information
danilobellini committed Sep 24, 2016
1 parent d695019 commit 5fdc62a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/watchdog/observers/inotify_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def remove_watch(self, path):
Path string for which the watch will be removed.
"""
with self._lock:
wd = self._remove_watch_bookkeeping(path)
wd = self._wd_for_path.pop(path)
del self._path_for_wd[wd]
if inotify_rm_watch(self._inotify_fd, wd) == -1:
Inotify._raise_error()

Expand Down Expand Up @@ -322,7 +323,9 @@ def _recursive_simulate(src_path):

if inotify_event.is_ignored:
# Clean up book-keeping for deleted watches.
self._remove_watch_bookkeeping(src_path)
path = self._path_for_wd.pop(wd)
if self._wd_for_path[path] == wd:
del self._wd_for_path[path]
continue

event_list.append(inotify_event)
Expand Down Expand Up @@ -387,11 +390,6 @@ def _add_watch(self, path, mask):
self._path_for_wd[wd] = path
return wd

def _remove_watch_bookkeeping(self, path):
wd = self._wd_for_path.pop(path)
del self._path_for_wd[wd]
return wd

@staticmethod
def _raise_error():
"""
Expand Down

0 comments on commit 5fdc62a

Please sign in to comment.