summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-09-09 10:45:50 +0200
committerSebastien Martini <seb@dbzteam.org>2010-09-09 10:45:50 +0200
commit80e1afc95893350e6e59230993e26376e279327c (patch)
tree94edc74faf77b4712443063d3d8bc5e0ee4d3be1
parent91e8a9ca4348576220e8268ecb8b3492b2e9c022 (diff)
downloadpyinotify-80e1afc95893350e6e59230993e26376e279327c.tar.gz
Added new method WatchManager.close() to close inotify's file
descriptor when needed (bug reported by jdw@research.att.com).
-rwxr-xr-xpython2/pyinotify.py12
-rwxr-xr-xpython3/pyinotify.py12
2 files changed, 24 insertions, 0 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index e10aa83..d7fb8af 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -1607,6 +1607,18 @@ class WatchManager:
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.
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index a2eda17..9a7afac 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -1555,6 +1555,18 @@ class WatchManager:
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.