summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpython2/pyinotify.py7
-rwxr-xr-xpython3/pyinotify.py7
2 files changed, 10 insertions, 4 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index e1b93c6..679e141 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -1405,9 +1405,12 @@ class Notifier:
Close inotify's instance (close its file descriptor).
It destroys all existing watches, pending events,...
This method is automatically called at the end of loop().
+ Afterward it is invalid to access this instance.
"""
- self._pollobj.unregister(self._fd)
- os.close(self._fd)
+ if self._fd is not None:
+ self._pollobj.unregister(self._fd)
+ os.close(self._fd)
+ self._fd = None
self._sys_proc_fun = None
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index 23fae15..9fb815e 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -1391,9 +1391,12 @@ class Notifier:
Close inotify's instance (close its file descriptor).
It destroys all existing watches, pending events,...
This method is automatically called at the end of loop().
+ Afterward it is invalid to access this instance.
"""
- self._pollobj.unregister(self._fd)
- os.close(self._fd)
+ if self._fd is not None:
+ self._pollobj.unregister(self._fd)
+ os.close(self._fd)
+ self._fd = None
self._sys_proc_fun = None