[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Catching unexpected exception from descriptor reader



commit 6bb517d876243aafd5cf3ae0eef7ecbe45958389
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Apr 20 12:25:18 2012 -0700

    Catching unexpected exception from descriptor reader
    
    The os.stat() call can raise an OSError, so catching that and notifying the
    skip listener.
---
 stem/descriptor/reader.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 83b29c6..0bddd53 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -357,9 +357,13 @@ class DescriptorReader:
     # This is a file. Register its last modified timestamp and check if
     # it's a file that we should skip.
     
-    last_modified = int(os.stat(target).st_mtime)
-    last_used = self._processed_files.get(target)
-    new_processed_files[target] = last_modified
+    try:
+      last_modified = int(os.stat(target).st_mtime)
+      last_used = self._processed_files.get(target)
+      new_processed_files[target] = last_modified
+    except OSError, exc:
+      self._notify_skip_listeners(target, ReadFailed(exc))
+      return
     
     if last_used and last_used >= last_modified:
       self._notify_skip_listeners(target, AlreadyRead(last_modified, last_used))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits