[Erp5-report] r39585 nicolas.dumazet - /erp5/trunk/products/ERP5Type/ConnectionPlugin/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 28 08:58:20 CEST 2010


Author: nicolas.dumazet
Date: Thu Oct 28 08:58:19 2010
New Revision: 39585

URL: http://svn.erp5.org?rev=39585&view=rev
Log:
Do not let socket.error go through, ProtocolError should be raised instead

Modified:
    erp5/trunk/products/ERP5Type/ConnectionPlugin/TimeoutTransport.py

Modified: erp5/trunk/products/ERP5Type/ConnectionPlugin/TimeoutTransport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ConnectionPlugin/TimeoutTransport.py?rev=39585&r1=39584&r2=39585&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ConnectionPlugin/TimeoutTransport.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ConnectionPlugin/TimeoutTransport.py [utf8] Thu Oct 28 08:58:19 2010
@@ -26,9 +26,10 @@
 #
 ##############################################################################
 
-from xmlrpclib import Fault
+from xmlrpclib import Fault, ProtocolError
 from xmlrpclib import Transport
 from xmlrpclib import SafeTransport
+import socket
 
 class TimeoutTransport(SafeTransport):
   """A xmlrpc transport with configurable timeout.
@@ -45,15 +46,22 @@ class TimeoutTransport(SafeTransport):
     super__init__(self)
 
   def send_content(self, connection, request_body):
-    connection.putheader("Content-Type", "text/xml")
-    connection.putheader("Content-Length", str(len(request_body)))
-    connection.endheaders()
-    if self._timeout:
-      connection._conn.sock.settimeout(self._timeout)
-    if request_body:
-      connection.send(request_body)
+    try:
+      connection.putheader("Content-Type", "text/xml")
+      connection.putheader("Content-Length", str(len(request_body)))
+      connection.endheaders()
+      if self._timeout:
+        connection._conn.sock.settimeout(self._timeout)
+      if request_body:
+        connection.send(request_body)
+    except socket.error, e:
+      raise ProtocolError(connection._conn.host, -1,
+                          "Could not connect to server", None)
 
-  def make_connection(self, h):
-    if self._scheme == 'http':
-      return Transport.make_connection(self, h)
-    return SafeTransport.make_connection(self, h)
+  def make_connection(self, host):
+    try:
+      if self._scheme == 'http':
+        return Transport.make_connection(self, host)
+      return SafeTransport.make_connection(self, host)
+    except socket.error, e:
+      raise ProtocolError(host, -1, "Could not connect to server", None)




More information about the Erp5-report mailing list