diff options
author | Sebastien Martini <seb@dbzteam.org> | 2015-06-04 15:23:17 +0200 |
---|---|---|
committer | Sebastien Martini <seb@dbzteam.org> | 2015-06-04 15:23:17 +0200 |
commit | 7da6df4a4f7d99ef03445ecd3b738a535d9315f6 (patch) | |
tree | d43abdc02e5383f1a0bc1aa3ac99f8a424547e94 /python3/pyinotify.py | |
parent | b142abf409fc206d8acd5a021574f5b326022f84 (diff) | |
download | pyinotify-7da6df4a4f7d99ef03445ecd3b738a535d9315f6.tar.gz |
Only close a valid file descriptor
Idea contributed by @blueyed
Close #93
Diffstat (limited to 'python3/pyinotify.py')
-rwxr-xr-x | python3/pyinotify.py | 7 |
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 |