Merge lp:~jfb-tempo-consulting/unifield-server/US-7030 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5630
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-7030
Merge into: lp:unifield-server
Diff against target: 76 lines (+14/-5)
2 files modified
bin/addons/sync_client/rpc.py (+9/-4)
bin/addons/sync_client/timeout_transport.py (+5/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-7030
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+378642@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/sync_client/rpc.py'
2--- bin/addons/sync_client/rpc.py 2017-05-09 15:04:38 +0000
3+++ bin/addons/sync_client/rpc.py 2020-02-06 09:41:40 +0000
4@@ -9,7 +9,7 @@
5 import socket
6 import zlib
7 import xmlrpclib
8-from timeout_transport import TimeoutTransport
9+from timeout_transport import TimeoutTransport, TimeoutSafeTransport
10 from osv import osv
11 from tools.translate import _
12 import tools
13@@ -106,7 +106,7 @@
14 error = e
15 if i < self.retry:
16 retry = True
17- self._logger.debug("retry to connect %s, error : %s" ,i, e)
18+ self._logger.warn("retry to connect %s, error : %s" ,i, e)
19 i += 1
20 if error:
21 raise osv.except_osv(_('Error!'), "Unable to proceed for the following reason:\n%s" % (e.faultCode if hasattr(e, 'faultCode') else tools.ustr(e)))
22@@ -120,16 +120,21 @@
23
24 def __init__(self, hostname, port=8070, timeout=10.0, retry=0):
25 XmlRPCConnector.__init__(self, hostname, port, timeout=timeout, retry=retry)
26+ self.timeout = timeout
27 self.url = 'https://%s:%s/xmlrpc' % (self.hostname, self.port)
28
29 def send(self, service_name, method, *args):
30 url = '%s/%s' % (self.url, service_name)
31 # Decide whether to accept self-signed certificates
32 ctx = ssl.create_default_context()
33+ transport = TimeoutSafeTransport(timeout=self.timeout)
34+ # Enable gzip on all payloads
35+ transport.encode_threshold = 0
36 if not tools.config.get('secure_verify', True):
37 ctx.check_hostname = False
38 ctx.verify_mode = ssl.CERT_NONE
39- service = xmlrpclib.ServerProxy(url, allow_none=1, context=ctx)
40+ service = xmlrpclib.ServerProxy(url, allow_none=1, context=ctx, transport=transport)
41+
42 return self._send(service, method, *args)
43
44 class NetRPC_Exception(Exception):
45@@ -392,7 +397,7 @@
46 return arguments
47
48 def exists(self, oid, context=None):
49- # TODO: Fucking bug, we can't use the read(fields=['id']),
50+ # TODO: Fucking bug, we can't use the read(fields=['id']),
51 # because the server returns a positive value but the record does not exist
52 # into the database
53 value = self.search_count([('id', '=', oid)], context=context)
54
55=== modified file 'bin/addons/sync_client/timeout_transport.py'
56--- bin/addons/sync_client/timeout_transport.py 2017-05-09 15:04:38 +0000
57+++ bin/addons/sync_client/timeout_transport.py 2020-02-06 09:41:40 +0000
58@@ -30,6 +30,9 @@
59 if self.timeout is not None:
60 self.sock.settimeout(self.timeout)
61
62+ def set_timeout(self, timeout):
63+ self.timeout = timeout
64+
65 class TimeoutSafeTransport(xmlrpclib.SafeTransport):
66
67 def __init__(self, timeout=None, *args, **kwargs):
68@@ -37,7 +40,8 @@
69 self.timeout = timeout
70
71 def make_connection(self, host):
72- self._connection = host, TimeoutHTTPSConnection(host)
73+ chost, self._extra_headers, _ = self.get_host_info(host)
74+ self._connection = host, TimeoutHTTPSConnection(chost)
75 self._connection[1].set_timeout(self.timeout)
76 return self._connection[1]
77

Subscribers

People subscribed via source and target branches