diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-01-21 13:53:59 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-01-23 11:31:58 +0000 |
| commit | 8da8a0e55e7191b81e6e0fd1d2d4f0937ba7b0ac (patch) | |
| tree | fe93515c98838fc47abb94715f17607f85f3102e | |
| parent | 6abcc6118d068266947d6fd5acf78f744ec02cb6 (diff) | |
| download | poky-8da8a0e55e7191b81e6e0fd1d2d4f0937ba7b0ac.tar.gz | |
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>
| -rw-r--r-- | bitbake/lib/prserv/serv.py | 14 |
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): | |||
| 77 | 77 | ||
| 78 | """ | 78 | """ |
| 79 | iter_count = 1 | 79 | iter_count = 1 |
| 80 | # With 60 iterations between syncs and a 0.5 second timeout between | 80 | # 60 iterations between syncs or sync if dirty every ~30 seconds |
| 81 | # iterations, this will sync if dirty every ~30 seconds. | ||
| 82 | iterations_between_sync = 60 | 81 | iterations_between_sync = 60 |
| 83 | 82 | ||
| 84 | while True: | 83 | while not self.quit: |
| 85 | (request, client_address) = self.requestqueue.get() | 84 | try: |
| 85 | (request, client_address) = self.requestqueue.get(True, 30) | ||
| 86 | except Queue.Empty: | ||
| 87 | self.table.sync_if_dirty() | ||
| 88 | continue | ||
| 86 | try: | 89 | try: |
| 87 | self.finish_request(request, client_address) | 90 | self.finish_request(request, client_address) |
| 88 | self.shutdown_request(request) | 91 | self.shutdown_request(request) |
| @@ -93,6 +96,7 @@ class PRServer(SimpleXMLRPCServer): | |||
| 93 | self.handle_error(request, client_address) | 96 | self.handle_error(request, client_address) |
| 94 | self.shutdown_request(request) | 97 | self.shutdown_request(request) |
| 95 | self.table.sync() | 98 | self.table.sync() |
| 99 | self.table.sync_if_dirty() | ||
| 96 | 100 | ||
| 97 | def process_request(self, request, client_address): | 101 | def process_request(self, request, client_address): |
| 98 | self.requestqueue.put((request, client_address)) | 102 | self.requestqueue.put((request, client_address)) |
| @@ -137,7 +141,7 @@ class PRServer(SimpleXMLRPCServer): | |||
| 137 | self.handlerthread.start() | 141 | self.handlerthread.start() |
| 138 | while not self.quit: | 142 | while not self.quit: |
| 139 | self.handle_request() | 143 | self.handle_request() |
| 140 | 144 | self.handlerthread.join() | |
| 141 | self.table.sync() | 145 | self.table.sync() |
| 142 | logger.info("PRServer: stopping...") | 146 | logger.info("PRServer: stopping...") |
| 143 | self.server_close() | 147 | self.server_close() |
