Commits

coady committed 6dc52e7

Thread safety for synchronization failover.

  • Participants
  • Parent commits 022869b

Comments (0)

Files changed (2)

         except socket.error:
             self[host].failure = time.time()
             if method != 'GET':
-                del self.hosts[0]
+                try:
+                    self.hosts.remove(host)
+                except ValueError:
+                    pass
             return self.call(method, path, body, retry=retry)
         return response if (response or not retry) else self.call(method, path, body, retry=retry-1)
         """
         names = ()
         while self.hosts:
+            host = self.hosts[0]
             try:
-                names = self.sync(*self.hosts[0].split('/'))
+                names = self.sync(*host.split('/'))
                 break
             except socket.error:
-                del self.hosts[0]
+                try:
+                    self.hosts.remove(host)
+                except ValueError:
+                    pass
             except httplib.HTTPException as exc:
                 assert exc[0] == httplib.METHOD_NOT_ALLOWED, exc
                 break