summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/prserv/serv.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index d6f3f44b04..3677f77c80 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -31,19 +31,20 @@ class Handler(SimpleXMLRPCRequestHandler):
31PIDPREFIX = "/tmp/PRServer_%s_%s.pid" 31PIDPREFIX = "/tmp/PRServer_%s_%s.pid"
32singleton = None 32singleton = None
33 33
34class PRServer(SimpleXMLRPCServer): 34import SocketServer
35class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
36 pass
37
38class PRServer(SimpleThreadedXMLRPCServer):
35 def __init__(self, dbfile, logfile, interface, daemon=True): 39 def __init__(self, dbfile, logfile, interface, daemon=True):
36 ''' constructor ''' 40 ''' constructor '''
37 SimpleXMLRPCServer.__init__(self, interface, 41 SimpleThreadedXMLRPCServer.__init__(self, interface,
38 requestHandler=SimpleXMLRPCRequestHandler,
39 logRequests=False, allow_none=True) 42 logRequests=False, allow_none=True)
40 self.dbfile=dbfile 43 self.dbfile=dbfile
41 self.daemon=daemon 44 self.daemon=daemon
42 self.logfile=logfile 45 self.logfile=logfile
43 self.working_thread=None 46 self.working_thread=None
44 self.host, self.port = self.socket.getsockname() 47 self.host, self.port = self.socket.getsockname()
45 self.db=prserv.db.PRData(dbfile)
46 self.table=self.db["PRMAIN"]
47 self.pidfile=PIDPREFIX % (self.host, self.port) 48 self.pidfile=PIDPREFIX % (self.host, self.port)
48 49
49 self.register_function(self.getPR, "getPR") 50 self.register_function(self.getPR, "getPR")
@@ -55,13 +56,17 @@ class PRServer(SimpleXMLRPCServer):
55 56
56 def export(self, version=None, pkgarch=None, checksum=None, colinfo=True): 57 def export(self, version=None, pkgarch=None, checksum=None, colinfo=True):
57 try: 58 try:
58 return self.table.export(version, pkgarch, checksum, colinfo) 59 db = prserv.db.PRData(self.dbfile)
60 table = db["PRMAIN"]
61 return table.export(version, pkgarch, checksum, colinfo)
59 except sqlite3.Error as exc: 62 except sqlite3.Error as exc:
60 logger.error(str(exc)) 63 logger.error(str(exc))
61 return None 64 return None
62 65
63 def importone(self, version, pkgarch, checksum, value): 66 def importone(self, version, pkgarch, checksum, value):
64 return self.table.importone(version, pkgarch, checksum, value) 67 db = prserv.db.PRData(self.dbfile)
68 table = db["PRMAIN"]
69 return table.importone(version, pkgarch, checksum, value)
65 70
66 def ping(self): 71 def ping(self):
67 return not self.quit 72 return not self.quit
@@ -71,7 +76,9 @@ class PRServer(SimpleXMLRPCServer):
71 76
72 def getPR(self, version, pkgarch, checksum): 77 def getPR(self, version, pkgarch, checksum):
73 try: 78 try:
74 return self.table.getValue(version, pkgarch, checksum) 79 db = prserv.db.PRData(self.dbfile)
80 table = db["PRMAIN"]
81 return table.getValue(version, pkgarch, checksum)
75 except prserv.NotFoundError: 82 except prserv.NotFoundError:
76 logger.error("can not find value for (%s, %s)",version, checksum) 83 logger.error("can not find value for (%s, %s)",version, checksum)
77 return None 84 return None
@@ -177,7 +184,6 @@ class PRServSingleton(object):
177 self.prserv = PRServer(self.dbfile, self.logfile, self.interface) 184 self.prserv = PRServer(self.dbfile, self.logfile, self.interface)
178 self.prserv.start() 185 self.prserv.start()
179 self.host, self.port = self.prserv.getinfo() 186 self.host, self.port = self.prserv.getinfo()
180 del self.prserv.db
181 187
182 def getinfo(self): 188 def getinfo(self):
183 return (self.host, self.port) 189 return (self.host, self.port)