summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-02 10:20:06 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-02 23:41:00 +0100
commitab4cc02bf87c1b78933c221a29f187d05427ed08 (patch)
tree322a7d4437dbae4916267a868a1a7fd2d6111fa6
parent01c1167336e5e75077ceb46b6cc43981e09317f6 (diff)
downloadpoky-ab4cc02bf87c1b78933c221a29f187d05427ed08.tar.gz
poky-ab4cc02bf87c1b78933c221a29f187d05427ed08.tar.bz2
poky-ab4cc02bf87c1b78933c221a29f187d05427ed08.zip
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: bd9d827ae6ef02ec9a0577fb2fd19b830ccb4416) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4) Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/prserv/serv.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 25eb46a410..a7639c8c2d 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -77,12 +77,15 @@ class PRServer(SimpleXMLRPCServer):
"""
iter_count = 1
- # With 60 iterations between syncs and a 0.5 second timeout between
- # iterations, this will sync if dirty every ~30 seconds.
+ # 60 iterations between syncs or sync if dirty every ~30 seconds
iterations_between_sync = 60
- while True:
- (request, client_address) = self.requestqueue.get()
+ while not self.quit:
+ try:
+ (request, client_address) = self.requestqueue.get(True, 30)
+ except Queue.Empty:
+ self.table.sync_if_dirty()
+ continue
try:
self.finish_request(request, client_address)
self.shutdown_request(request)
@@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer):
self.handle_error(request, client_address)
self.shutdown_request(request)
self.table.sync()
+ self.table.sync_if_dirty()
def process_request(self, request, client_address):
self.requestqueue.put((request, client_address))
@@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer):
self.handlerthread.start()
while not self.quit:
self.handle_request()
-
+ self.handlerthread.join()
self.table.sync()
logger.info("PRServer: stopping...")
self.server_close()