prserv/serv: Improve exit handling
PATCH 1/1 prserv/serv: Improve exit handling
From: Richard Purdie <[email protected]>
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)
--- lib/prserv/serv.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
lib/prserv/serv.py +9 -5
@@ -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()
Signature · 1 line
2.1.0
Quoted 1 line · Saul Wold
From: Richard Purdie <[email protected]>
The subject doesn't say for which branch this is intended.
I guess 1.24, because it's already in 1.26 and master, but it should be specified in Subject.
Quoted 69 lines
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)Signed-off-by Richard Purdie <[email protected]>(cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4)Signed-off-by Saul Wold <[email protected]>--- lib/prserv/serv.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)lib/prserv/serv.py +9
-5@@ -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()Signature · 7 lines
2.1.0 -- _______________________________________________ bitbake-devel mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/bitbake-devel
Signature · 1 line
Martin 'JaMa' Jansa jabber: [email protected]
Quoted 8 lines · Martin Jansa
Quoted 1 line · Saul Wold
From: Richard Purdie <[email protected]>
The subject doesn't say for which branch this is intended.
I guess 1.24, because it's already in 1.26 and master, but it should be specified in Subject.
Yes it is for 1.24, I can resend, but I think RP knows that this is for 1.24 also.
Sau!
Quoted 70 lines
Quoted 69 lines
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)Signed-off-by Richard Purdie <[email protected]>(cherry picked from commit 0926492295d485813d8a4f6b77c7b152e4c5b4c4)Signed-off-by Saul Wold <[email protected]>--- lib/prserv/serv.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)lib/prserv/serv.py +9
-6@@ -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() --2.1.0
--
_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel