summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r--bitbake/lib/bb/server/process.py8
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py48
2 files changed, 29 insertions, 27 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index cc58c720a2..982fcf71c3 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -30,7 +30,7 @@ import signal
30import sys 30import sys
31import time 31import time
32import select 32import select
33from Queue import Empty 33from queue import Empty
34from multiprocessing import Event, Process, util, Queue, Pipe, queues, Manager 34from multiprocessing import Event, Process, util, Queue, Pipe, queues, Manager
35 35
36from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer 36from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
@@ -137,7 +137,7 @@ class ProcessServer(Process, BaseImplServer):
137 if not fds: 137 if not fds:
138 fds = [] 138 fds = []
139 139
140 for function, data in self._idlefuns.items(): 140 for function, data in list(self._idlefuns.items()):
141 try: 141 try:
142 retval = function(self, data, False) 142 retval = function(self, data, False)
143 if retval is False: 143 if retval is False:
@@ -145,7 +145,7 @@ class ProcessServer(Process, BaseImplServer):
145 nextsleep = None 145 nextsleep = None
146 elif retval is True: 146 elif retval is True:
147 nextsleep = None 147 nextsleep = None
148 elif isinstance(retval, float): 148 elif isinstance(retval, float) and nextsleep:
149 if (retval < nextsleep): 149 if (retval < nextsleep):
150 nextsleep = retval 150 nextsleep = retval
151 elif nextsleep is None: 151 elif nextsleep is None:
@@ -213,7 +213,7 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
213# Wrap Queue to provide API which isn't server implementation specific 213# Wrap Queue to provide API which isn't server implementation specific
214class ProcessEventQueue(multiprocessing.queues.Queue): 214class ProcessEventQueue(multiprocessing.queues.Queue):
215 def __init__(self, maxsize): 215 def __init__(self, maxsize):
216 multiprocessing.queues.Queue.__init__(self, maxsize) 216 multiprocessing.queues.Queue.__init__(self, maxsize, ctx=multiprocessing.get_context())
217 self.exit = False 217 self.exit = False
218 bb.utils.set_process_name("ProcessEQueue") 218 bb.utils.set_process_name("ProcessEQueue")
219 219
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index ace1cf646b..146ca17b51 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -31,31 +31,33 @@
31 in the server's main loop. 31 in the server's main loop.
32""" 32"""
33 33
34import os
35import sys
36
37import hashlib
38import time
39import socket
40import signal
41import threading
42import pickle
43import inspect
44import select
45import http.client
46import xmlrpc.client
47from xmlrpc.server import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
48
34import bb 49import bb
35import xmlrpclib, sys
36from bb import daemonize 50from bb import daemonize
37from bb.ui import uievent 51from bb.ui import uievent
38import hashlib, time 52from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
39import socket
40import os, signal
41import threading
42try:
43 import cPickle as pickle
44except ImportError:
45 import pickle
46 53
47DEBUG = False 54DEBUG = False
48 55
49from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler 56class BBTransport(xmlrpc.client.Transport):
50import inspect, select, httplib
51
52from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
53
54class BBTransport(xmlrpclib.Transport):
55 def __init__(self, timeout): 57 def __init__(self, timeout):
56 self.timeout = timeout 58 self.timeout = timeout
57 self.connection_token = None 59 self.connection_token = None
58 xmlrpclib.Transport.__init__(self) 60 xmlrpc.client.Transport.__init__(self)
59 61
60 # Modified from default to pass timeout to HTTPConnection 62 # Modified from default to pass timeout to HTTPConnection
61 def make_connection(self, host): 63 def make_connection(self, host):
@@ -67,7 +69,7 @@ class BBTransport(xmlrpclib.Transport):
67 # create a HTTP connection object from a host descriptor 69 # create a HTTP connection object from a host descriptor
68 chost, self._extra_headers, x509 = self.get_host_info(host) 70 chost, self._extra_headers, x509 = self.get_host_info(host)
69 #store the host argument along with the connection object 71 #store the host argument along with the connection object
70 self._connection = host, httplib.HTTPConnection(chost, timeout=self.timeout) 72 self._connection = host, http.client.HTTPConnection(chost, timeout=self.timeout)
71 return self._connection[1] 73 return self._connection[1]
72 74
73 def set_connection_token(self, token): 75 def set_connection_token(self, token):
@@ -76,11 +78,11 @@ class BBTransport(xmlrpclib.Transport):
76 def send_content(self, h, body): 78 def send_content(self, h, body):
77 if self.connection_token: 79 if self.connection_token:
78 h.putheader("Bitbake-token", self.connection_token) 80 h.putheader("Bitbake-token", self.connection_token)
79 xmlrpclib.Transport.send_content(self, h, body) 81 xmlrpc.client.Transport.send_content(self, h, body)
80 82
81def _create_server(host, port, timeout = 60): 83def _create_server(host, port, timeout = 60):
82 t = BBTransport(timeout) 84 t = BBTransport(timeout)
83 s = xmlrpclib.ServerProxy("http://%s:%d/" % (host, port), transport=t, allow_none=True) 85 s = xmlrpc.client.ServerProxy("http://%s:%d/" % (host, port), transport=t, allow_none=True, use_builtin_types=True)
84 return s, t 86 return s, t
85 87
86class BitBakeServerCommands(): 88class BitBakeServerCommands():
@@ -128,7 +130,7 @@ class BitBakeServerCommands():
128 def addClient(self): 130 def addClient(self):
129 if self.has_client: 131 if self.has_client:
130 return None 132 return None
131 token = hashlib.md5(str(time.time())).hexdigest() 133 token = hashlib.md5(str(time.time()).encode("utf-8")).hexdigest()
132 self.server.set_connection_token(token) 134 self.server.set_connection_token(token)
133 self.has_client = True 135 self.has_client = True
134 return token 136 return token
@@ -232,7 +234,7 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
232 while not self.quit: 234 while not self.quit:
233 fds = [self] 235 fds = [self]
234 nextsleep = 0.1 236 nextsleep = 0.1
235 for function, data in self._idlefuns.items(): 237 for function, data in list(self._idlefuns.items()):
236 retval = None 238 retval = None
237 try: 239 try:
238 retval = function(self, data, False) 240 retval = function(self, data, False)
@@ -267,7 +269,7 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
267 pass 269 pass
268 270
269 # Tell idle functions we're exiting 271 # Tell idle functions we're exiting
270 for function, data in self._idlefuns.items(): 272 for function, data in list(self._idlefuns.items()):
271 try: 273 try:
272 retval = function(self, data, True) 274 retval = function(self, data, True)
273 except: 275 except:
@@ -379,7 +381,7 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
379 bb.warn("Could not create socket for %s:%s (%s)" % (host, port, str(e))) 381 bb.warn("Could not create socket for %s:%s (%s)" % (host, port, str(e)))
380 raise e 382 raise e
381 try: 383 try:
382 self.serverImpl = XMLRPCProxyServer(host, port) 384 self.serverImpl = XMLRPCProxyServer(host, port, use_builtin_types=True)
383 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset) 385 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset)
384 return self.connection.connect(self.token) 386 return self.connection.connect(self.token)
385 except Exception as e: 387 except Exception as e: