• R/O
  • SSH
  • HTTPS

o2on: Commit


Commit MetaInfo

Revision179 (tree)
Zeit2010-02-16 22:15:15
Autornawota

Log Message

Check if read is completed.

Ändern Zusammenfassung

Diff

--- trunk/opy2on/lib/o2on_node.py (revision 178)
+++ trunk/opy2on/lib/o2on_node.py (revision 179)
@@ -246,7 +246,7 @@
246246 data = r.read(l)
247247 elif r.status == 404: pass
248248 else: raise Exception("status error %d" % r.status)
249- except socket.error:
249+ except socket.error, httplib.IncompleteRead:
250250 pass
251251 else:
252252 if data:
@@ -279,8 +279,11 @@
279279 r = self.request("POST","/dat", data,headers)
280280 else:
281281 r = self.request("GET","/dat",None,headers)
282- stat = r.status
283- data = r.read()
282+ try:
283+ stat = r.status
284+ data = r.read()
285+ except socket.error, httplib.IncompleteRead:
286+ return None
284287 if stat == 200:
285288 path = None
286289 path = r.getheader("X-O2-Original-DAT-URL")
@@ -303,7 +306,10 @@
303306 l = r.getheader('Content-Length')
304307 if l: l = int(l)
305308 else: return False
306- return r.read(l)
309+ try:
310+ return r.read(l)
311+ except socket.error, httplib.IncompleteRead:
312+ return False
307313 else: raise Exception("ping status %d" % r.status)
308314 return False
309315 def collection(self, glob):
@@ -313,7 +319,10 @@
313319 r = self.request("POST","/collection",board_xml,headers)
314320 result = []
315321 if r.status == 200:
316- data = r.read()
322+ try:
323+ data = r.read()
324+ except socket.error, httplib.IncompleteRead:
325+ return result
317326 # 本家o2on の bug 対策
318327 if data.rfind("</boards>") == -1:
319328 index = data.rfind("<boards>")
@@ -330,9 +339,13 @@
330339 def findvalue(self, kid):
331340 headers = {"X-O2-Target-Key":hexlify(kid)}
332341 r = self.request("GET","/findvalue",None,headers)
342+ try:
343+ data = r.read()
344+ except socket.error, httplib.IncompleteRead:
345+ return []
333346 if r.status == 200:
334347 res = []
335- dom = xml.dom.minidom.parseString(r.read())
348+ dom = xml.dom.minidom.parseString(data)
336349 nodes = dom.getElementsByTagName("nodes")
337350 keys = dom.getElementsByTagName("keys")
338351 if len(nodes):
Show on old repository browser