diff options
-rw-r--r-- | bitbake/lib/bb/server/xmlrpc.py | 22 | ||||
-rw-r--r-- | bitbake/lib/prserv/serv.py | 3 |
2 files changed, 18 insertions, 7 deletions
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py index 026415efd5..d290550e9f 100644 --- a/bitbake/lib/bb/server/xmlrpc.py +++ b/bitbake/lib/bb/server/xmlrpc.py | |||
@@ -47,15 +47,29 @@ except ImportError: | |||
47 | DEBUG = False | 47 | DEBUG = False |
48 | 48 | ||
49 | from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler | 49 | from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler |
50 | import inspect, select | 50 | import inspect, select, httplib |
51 | 51 | ||
52 | from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer | 52 | from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer |
53 | 53 | ||
54 | class BBTransport(xmlrpclib.Transport): | 54 | class BBTransport(xmlrpclib.Transport): |
55 | def __init__(self): | 55 | def __init__(self, timeout): |
56 | self.timeout = timeout | ||
56 | self.connection_token = None | 57 | self.connection_token = None |
57 | xmlrpclib.Transport.__init__(self) | 58 | xmlrpclib.Transport.__init__(self) |
58 | 59 | ||
60 | # Modified from default to pass timeout to HTTPConnection | ||
61 | def make_connection(self, host): | ||
62 | #return an existing connection if possible. This allows | ||
63 | #HTTP/1.1 keep-alive. | ||
64 | if self._connection and host == self._connection[0]: | ||
65 | return self._connection[1] | ||
66 | |||
67 | # create a HTTP connection object from a host descriptor | ||
68 | chost, self._extra_headers, x509 = self.get_host_info(host) | ||
69 | #store the host argument along with the connection object | ||
70 | self._connection = host, httplib.HTTPConnection(chost, timeout=self.timeout) | ||
71 | return self._connection[1] | ||
72 | |||
59 | def set_connection_token(self, token): | 73 | def set_connection_token(self, token): |
60 | self.connection_token = token | 74 | self.connection_token = token |
61 | 75 | ||
@@ -64,8 +78,8 @@ class BBTransport(xmlrpclib.Transport): | |||
64 | h.putheader("Bitbake-token", self.connection_token) | 78 | h.putheader("Bitbake-token", self.connection_token) |
65 | xmlrpclib.Transport.send_content(self, h, body) | 79 | xmlrpclib.Transport.send_content(self, h, body) |
66 | 80 | ||
67 | def _create_server(host, port): | 81 | def _create_server(host, port, timeout = 5): |
68 | t = BBTransport() | 82 | t = BBTransport(timeout) |
69 | s = xmlrpclib.Server("http://%s:%d/" % (host, port), transport=t, allow_none=True) | 83 | s = xmlrpclib.Server("http://%s:%d/" % (host, port), transport=t, allow_none=True) |
70 | return s, t | 84 | return s, t |
71 | 85 | ||
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py index b854686c1a..81b4f8d069 100644 --- a/bitbake/lib/prserv/serv.py +++ b/bitbake/lib/prserv/serv.py | |||
@@ -186,9 +186,6 @@ class PRServerConnection(): | |||
186 | self.connection, self.transport = bb.server.xmlrpc._create_server(self.host, self.port) | 186 | self.connection, self.transport = bb.server.xmlrpc._create_server(self.host, self.port) |
187 | 187 | ||
188 | def terminate(self): | 188 | def terminate(self): |
189 | # Don't wait for server indefinitely | ||
190 | import socket | ||
191 | socket.setdefaulttimeout(2) | ||
192 | try: | 189 | try: |
193 | logger.info("Terminating PRServer...") | 190 | logger.info("Terminating PRServer...") |
194 | self.connection.quit() | 191 | self.connection.quit() |