[IMP] remove timeouting XMLRPC socket
bzr revid: xmo@openerp.com-20110504064642-48u0giakycwqufwr
This commit is contained in:
@@ -16,7 +16,6 @@ import cherrypy.lib.static
|
||||
import simplejson
|
||||
|
||||
import nonliterals
|
||||
import xmlrpctimeout
|
||||
import logging
|
||||
|
||||
#-----------------------------------------------------------
|
||||
@@ -93,8 +92,6 @@ class OpenERPSession(object):
|
||||
self.client_timezone = False
|
||||
|
||||
def proxy(self, service):
|
||||
# TODO: correct this bug with timeout connections not working in python 2.7
|
||||
# s = xmlrpctimeout.TimeoutServerProxy('http://%s:%s/xmlrpc/%s' % (self._server, self._port, service), timeout=5)
|
||||
s = xmlrpclib.ServerProxy('http://%s:%s/xmlrpc/%s' % (self._server, self._port, service))
|
||||
return s
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import xmlrpclib
|
||||
import httplib
|
||||
|
||||
class TimeoutHTTPConnection(httplib.HTTPConnection):
|
||||
def connect(self):
|
||||
httplib.HTTPConnection.connect(self)
|
||||
self.sock.settimeout(self.timeout)
|
||||
|
||||
class TimeoutHTTP(httplib.HTTP):
|
||||
_connection_class = TimeoutHTTPConnection
|
||||
def set_timeout(self, timeout):
|
||||
self._conn.timeout = timeout
|
||||
|
||||
class TimeoutTransport(xmlrpclib.Transport):
|
||||
def __init__(self, timeout=10, *l, **kw):
|
||||
xmlrpclib.Transport.__init__(self,*l,**kw)
|
||||
self.timeout=timeout
|
||||
def make_connection(self, host):
|
||||
conn = TimeoutHTTP(host)
|
||||
conn.set_timeout(self.timeout)
|
||||
return conn
|
||||
|
||||
class TimeoutServerProxy(xmlrpclib.ServerProxy):
|
||||
def __init__(self,uri,timeout=10,*l,**kw):
|
||||
kw['transport']=TimeoutTransport(timeout=timeout, use_datetime=kw.get('use_datetime',0))
|
||||
xmlrpclib.ServerProxy.__init__(self,uri,*l,**kw)
|
||||
|
||||
if __name__ == "__main__":
|
||||
s=TimeoutServerProxy('http://127.0.0.1:9090',timeout=2)
|
||||
s.dummy()
|
||||
Reference in New Issue
Block a user