mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
bitbake: prserv/serv: Improve exit handling
Currently, I'm not sure how the prserver managed to shut down cleanly. These issues may explain some of the hangs people have reported. This change: * Ensures the connection acceptance thread monitors self.quit * We wait for the thread to exit before exitting * We sync the database when the thread exits * We do what the comment mentions, timeout after 30s and sync the database if needed. Previously, there was no timeout (the 0.5 applies to sockets, not the Queue object) (Bitbake rev: 0926492295d485813d8a4f6b77c7b152e4c5b4c4) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
iter_count = 1
|
iter_count = 1
|
||||||
# With 60 iterations between syncs and a 0.5 second timeout between
|
# 60 iterations between syncs or sync if dirty every ~30 seconds
|
||||||
# iterations, this will sync if dirty every ~30 seconds.
|
|
||||||
iterations_between_sync = 60
|
iterations_between_sync = 60
|
||||||
|
|
||||||
while True:
|
while not self.quit:
|
||||||
(request, client_address) = self.requestqueue.get()
|
try:
|
||||||
|
(request, client_address) = self.requestqueue.get(True, 30)
|
||||||
|
except Queue.Empty:
|
||||||
|
self.table.sync_if_dirty()
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
self.finish_request(request, client_address)
|
self.finish_request(request, client_address)
|
||||||
self.shutdown_request(request)
|
self.shutdown_request(request)
|
||||||
@@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
|
|||||||
self.handle_error(request, client_address)
|
self.handle_error(request, client_address)
|
||||||
self.shutdown_request(request)
|
self.shutdown_request(request)
|
||||||
self.table.sync()
|
self.table.sync()
|
||||||
|
self.table.sync_if_dirty()
|
||||||
|
|
||||||
def process_request(self, request, client_address):
|
def process_request(self, request, client_address):
|
||||||
self.requestqueue.put((request, client_address))
|
self.requestqueue.put((request, client_address))
|
||||||
@@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
|
|||||||
self.handlerthread.start()
|
self.handlerthread.start()
|
||||||
while not self.quit:
|
while not self.quit:
|
||||||
self.handle_request()
|
self.handle_request()
|
||||||
|
self.handlerthread.join()
|
||||||
self.table.sync()
|
self.table.sync()
|
||||||
logger.info("PRServer: stopping...")
|
logger.info("PRServer: stopping...")
|
||||||
self.server_close()
|
self.server_close()
|
||||||
|
|||||||
Reference in New Issue
Block a user