Skip to content

Commit

Permalink
Enables creating non-blocking Inotify instances
Browse files Browse the repository at this point in the history
Signed-off-by: Gora Khargosh <gora.khargosh@gmail.com>
  • Loading branch information
gorakhargosh committed Dec 11, 2010
1 parent fd7e5e7 commit a6cb1f9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions watchdog/observers/inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,10 @@ def __init__(self,
event_mask=Inotify.IN_ALL_EVENTS,
non_blocking=False):
# The file descriptor associated with the inotify instance.
#if non_blocking:
# inotify_fd = inotify_init1(Inotify.IN_NONBLOCK)
#else:
# inotify_fd = inotify_init()
inotify_fd = inotify_init()
if non_blocking:
inotify_fd = inotify_init1(Inotify.IN_NONBLOCK)
else:
inotify_fd = inotify_init()
if inotify_fd == -1:
Inotify._raise_error()
self._inotify_fd = inotify_fd
Expand Down Expand Up @@ -253,6 +252,11 @@ def is_recursive(self):
"""Whether we are watching directories recursively."""
return self._is_recursive

@property
def is_non_blocking(self):
"""Determines whether this instance of inotify is non-blocking."""
return self._is_non_blocking

@property
def fd(self):
"""The file descriptor associated with the inotify instance."""
Expand Down

0 comments on commit a6cb1f9

Please sign in to comment.