mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
bitbake: cooker/hashserv: Allow autostarting of a local hash server using BB_HASHSERVE
Its useful, particularly in the local developer model of usage, for bitbake to start and stop a hash equivalence server on local port, rather than relying on one being started by the user before the build. The new BB_HASHSERVE variable supports this. The database handling is moved internally into the hashserv code so that different threads/processes can be used for the server without errors. (Bitbake rev: a4fa8f1bd88995ae60e10430316fbed63d478587) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -18,8 +18,15 @@ class HashEquivalenceServer(BaseHTTPRequestHandler):
|
||||
def log_message(self, f, *args):
|
||||
logger.debug(f, *args)
|
||||
|
||||
def opendb(self):
|
||||
self.db = sqlite3.connect(self.dbname)
|
||||
self.db.row_factory = sqlite3.Row
|
||||
|
||||
def do_GET(self):
|
||||
try:
|
||||
if not self.db:
|
||||
self.opendb()
|
||||
|
||||
p = urllib.parse.urlparse(self.path)
|
||||
|
||||
if p.path != self.prefix + '/v1/equivalent':
|
||||
@@ -52,6 +59,9 @@ class HashEquivalenceServer(BaseHTTPRequestHandler):
|
||||
|
||||
def do_POST(self):
|
||||
try:
|
||||
if not self.db:
|
||||
self.opendb()
|
||||
|
||||
p = urllib.parse.urlparse(self.path)
|
||||
|
||||
if p.path != self.prefix + '/v1/equivalent':
|
||||
@@ -123,14 +133,17 @@ class HashEquivalenceServer(BaseHTTPRequestHandler):
|
||||
self.send_error(400, explain=traceback.format_exc())
|
||||
return
|
||||
|
||||
def create_server(addr, db, prefix=''):
|
||||
def create_server(addr, dbname, prefix=''):
|
||||
class Handler(HashEquivalenceServer):
|
||||
pass
|
||||
|
||||
Handler.prefix = prefix
|
||||
Handler.db = db
|
||||
db = sqlite3.connect(dbname)
|
||||
db.row_factory = sqlite3.Row
|
||||
|
||||
Handler.prefix = prefix
|
||||
Handler.db = None
|
||||
Handler.dbname = dbname
|
||||
|
||||
with contextlib.closing(db.cursor()) as cursor:
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS tasks_v2 (
|
||||
|
||||
Reference in New Issue
Block a user