path: root/bitbake
diff options
authorRichard Purdie <>2013-08-28 16:10:09 +0000
committerRichard Purdie <>2013-08-29 00:13:22 +0100
commitd5e860be4c12a9d6655665af391ffd6f9351f8eb (patch)
tree7556d284a5971422aaf476bea54a826c41bb7f33 /bitbake
parent06d76645900b2a7db8f88a0ad3bf4ae66cef52f1 (diff)
bitbake: prserv/serv: Multithread the server
This makes the PR server multithreaded and able to handle multiple connections at once which means its no longer a build bottle neck when serving one connection at a time. I've experimented and database connection for each thread seems to cause the least issues, pushing the contention for sqllite to handle itself. This means moving the db/table connection code into the actual function methods. It doesn't abstract well as a function since we need the db object around for the lifetime of the function as well as the table else we lose the connection. (Bitbake rev: bf9be2029b2bded5f532bdda4c38ae3dff5d1cf6) Signed-off-by: Richard Purdie <>
Diffstat (limited to 'bitbake')
1 files changed, 15 insertions, 9 deletions
diff --git a/bitbake/lib/prserv/ b/bitbake/lib/prserv/
index d6f3f44b04..3677f77c80 100644
--- a/bitbake/lib/prserv/
+++ b/bitbake/lib/prserv/
@@ -31,19 +31,20 @@ class Handler(SimpleXMLRPCRequestHandler):
PIDPREFIX = "/tmp/"
singleton = None
-class PRServer(SimpleXMLRPCServer):
+import SocketServer
+class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
+ pass
+class PRServer(SimpleThreadedXMLRPCServer):
def __init__(self, dbfile, logfile, interface, daemon=True):
''' constructor '''
- SimpleXMLRPCServer.__init__(self, interface,
- requestHandler=SimpleXMLRPCRequestHandler,
+ SimpleThreadedXMLRPCServer.__init__(self, interface,
logRequests=False, allow_none=True)
self.working_thread=None, self.port = self.socket.getsockname()
- self.db=prserv.db.PRData(dbfile)
- self.table=self.db["PRMAIN"]
self.pidfile=PIDPREFIX % (, self.port)
self.register_function(self.getPR, "getPR")
@@ -55,13 +56,17 @@ class PRServer(SimpleXMLRPCServer):
def export(self, version=None, pkgarch=None, checksum=None, colinfo=True):
- return self.table.export(version, pkgarch, checksum, colinfo)
+ db = prserv.db.PRData(self.dbfile)
+ table = db["PRMAIN"]
+ return table.export(version, pkgarch, checksum, colinfo)
except sqlite3.Error as exc:
return None
def importone(self, version, pkgarch, checksum, value):
- return self.table.importone(version, pkgarch, checksum, value)
+ db = prserv.db.PRData(self.dbfile)
+ table = db["PRMAIN"]
+ return table.importone(version, pkgarch, checksum, value)
def ping(self):
return not self.quit
@@ -71,7 +76,9 @@ class PRServer(SimpleXMLRPCServer):
def getPR(self, version, pkgarch, checksum):
- return self.table.getValue(version, pkgarch, checksum)
+ db = prserv.db.PRData(self.dbfile)
+ table = db["PRMAIN"]
+ return table.getValue(version, pkgarch, checksum)
except prserv.NotFoundError:
logger.error("can not find value for (%s, %s)",version, checksum)
return None
@@ -177,7 +184,6 @@ class PRServSingleton(object):
self.prserv = PRServer(self.dbfile, self.logfile, self.interface)
self.prserv.start(), self.port = self.prserv.getinfo()
- del self.prserv.db
def getinfo(self):
return (, self.port)