summaryrefslogtreecommitdiff
path: root/fs/osfs
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-09-13 09:45:13 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2010-09-13 09:45:13 +0000
commit60b6572d27a7cc5ec58dbc1ff3f577635db6d558 (patch)
treeaeca2f3e22ea5b67ccccbe88964061f3c383c2d8 /fs/osfs
parentcde2b6de0d739ab7e1447c622eeb953d2197e060 (diff)
downloadpyfilesystem-60b6572d27a7cc5ec58dbc1ff3f577635db6d558.tar.gz
osfs.watch_inotify: make background thread friendlier to interpreter shutdown
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@425 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/osfs')
-rw-r--r--fs/osfs/watch_inotify.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/osfs/watch_inotify.py b/fs/osfs/watch_inotify.py
index e8f20f2..883cb93 100644
--- a/fs/osfs/watch_inotify.py
+++ b/fs/osfs/watch_inotify.py
@@ -43,6 +43,7 @@ class OSFSWatchMixin(WatchableFSMixin):
wt = self.__watch_thread
if wt is not None and not wt.watchers:
wt.stop()
+ wt.join()
OSFSWatchMixin.__watch_thread = None
finally:
self.__watch_lock.release()
@@ -225,17 +226,22 @@ class SharedThreadedNotifier(threading.Thread):
self._poller.unregister(fd)
def run(self):
+ # Grab some attributes of the select module, so they're available
+ # even when shutting down the interpreter.
+ _select_error = select.error
+ _select_POLLIN = select.POLLIN
+ # Loop until stopped, dispatching to individual notifiers.
self.running = True
while self.running:
try:
ready_fds = self._poller.poll()
- except select.error, e:
+ except _select_error, e:
if e[0] != errno.EINTR:
raise
else:
for (fd,event) in ready_fds:
# Ignore all events other than "input ready".
- if not event & select.POLLIN:
+ if not event & _select_POLLIN:
continue
# For signals on our internal pipe, just read and discard.
if fd == self._pipe_r: