summaryrefslogtreecommitdiff
path: root/python3/pyinotify.py
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2015-06-04 15:23:17 +0200
committerSebastien Martini <seb@dbzteam.org>2015-06-04 15:23:17 +0200
commit7da6df4a4f7d99ef03445ecd3b738a535d9315f6 (patch)
treed43abdc02e5383f1a0bc1aa3ac99f8a424547e94 /python3/pyinotify.py
parentb142abf409fc206d8acd5a021574f5b326022f84 (diff)
downloadpyinotify-7da6df4a4f7d99ef03445ecd3b738a535d9315f6.tar.gz
Only close a valid file descriptor
Idea contributed by @blueyed Close #93
Diffstat (limited to 'python3/pyinotify.py')
-rwxr-xr-xpython3/pyinotify.py7
1 files changed, 5 insertions, 2 deletions
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