[CalendarServer-changes] [13413] twext/trunk/twext/who/xml.py

source_changes at macosforge.org source_changes at macosforge.org
Fri May 2 17:16:46 PDT 2014


Revision: 13413
          http://trac.calendarserver.org//changeset/13413
Author:   wsanchez at apple.com
Date:     2014-05-02 17:16:46 -0700 (Fri, 02 May 2014)
Log Message:
-----------
Handle I/O errors.

Modified Paths:
--------------
    twext/trunk/twext/who/xml.py

Modified: twext/trunk/twext/who/xml.py
===================================================================
--- twext/trunk/twext/who/xml.py	2014-05-03 00:01:34 UTC (rev 13412)
+++ twext/trunk/twext/who/xml.py	2014-05-03 00:16:46 UTC (rev 13413)
@@ -230,7 +230,13 @@
         # Punt if we've read the file and it's still the same.
         #
         if stat:
-            self.filePath.restat()
+            try:
+                self.filePath.restat()
+            except (OSError, IOError):
+                # Can't read the file
+                self.flush()
+                return
+
             cacheTag = (
                 self.filePath.getModificationTime(),
                 self.filePath.getsize()
@@ -243,14 +249,16 @@
         #
         # Open and parse the file
         #
-        fh = self.filePath.open()
         try:
-            try:
-                etree = parseXML(fh)
-            except XMLParseError as e:
-                raise ParseError(e)
-        finally:
-            fh.close()
+            with self.filePath.open() as fh:
+                try:
+                    etree = parseXML(fh)
+                except XMLParseError as e:
+                    raise ParseError(e)
+        except (OSError, IOError):
+            # Can't read the file
+            self.flush()
+            return
 
         #
         # Pull data from DOM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140502/5ec4a2cb/attachment.html>


More information about the calendarserver-changes mailing list