Skip to content

Commit

Permalink
Added new method WatchManager.close() to close inotify's file
Browse files Browse the repository at this point in the history
descriptor when needed (bug reported by [email protected]).
  • Loading branch information
seb-m committed Sep 9, 2010
1 parent 91e8a9c commit 80e1afc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python2/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,18 @@ def __init__(self, exclude_filter=lambda path: False):
err = 'Cannot initialize new instance of inotify%s' % strerrno()
raise OSError(err)

def close(self):
"""
Close inotify's file descriptor, this action will also automatically
remove (i.e. stop watching) all its associated watch descriptors.
After a call to this method the WatchManager's instance become useless
and cannot be reused, a new instance must then be instanciated. It
makes sense to call this method in few situations for instance if
several independant WatchManager must be instanciated or if all watches
must be removed and no other watches need to be added.
"""
os.close(self._fd)

def get_fd(self):
"""
Return assigned inotify's file descriptor.
Expand Down
12 changes: 12 additions & 0 deletions python3/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,18 @@ def __init__(self, exclude_filter=lambda path: False):
err = 'Cannot initialize new instance of inotify Errno=%s'
raise OSError(err % strerrno())

def close(self):
"""
Close inotify's file descriptor, this action will also automatically
remove (i.e. stop watching) all its associated watch descriptors.
After a call to this method the WatchManager's instance become useless
and cannot be reused, a new instance must then be instanciated. It
makes sense to call this method in few situations for instance if
several independant WatchManager must be instanciated or if all watches
must be removed and no other watches need to be added.
"""
os.close(self._fd)

def get_fd(self):
"""
Return assigned inotify's file descriptor.
Expand Down

0 comments on commit 80e1afc

Please sign in to comment.