diff options
author | Konrad Scherer <Konrad.Scherer@windriver.com> | 2013-11-15 15:51:47 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-18 17:19:11 +0000 |
commit | e15893adf9268b2920b24c52d5c2bb777c6f778e (patch) | |
tree | e5d05fff678bc62b1d52ce72428f5a98099beffb /bitbake/lib/prserv/serv.py | |
parent | 2354250a95eab484459f41f8715ae112295c2174 (diff) | |
download | poky-e15893adf9268b2920b24c52d5c2bb777c6f778e.tar.gz |
bitbake: serv.py: Give pr-server up to 5 seconds to commit data
The default value of 0.5 seconds before sending the pr-server a
SIGTERM is not enough to guarantee that sqlite has committed all
the pr data to the database. By polling the pid to see if it is
still running, this allows the pr-server process to shutdown
cleanly and finish the final pr data commit.
(Bitbake rev: 22eec978e70794923c85689928c6be0cfe71cdcd)
Signed-off-by: Konrad Scherer <Konrad.Scherer@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/serv.py')
-rw-r--r-- | bitbake/lib/prserv/serv.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py index 7864594bb6..e4c1c2a6aa 100644 --- a/bitbake/lib/prserv/serv.py +++ b/bitbake/lib/prserv/serv.py | |||
@@ -13,6 +13,7 @@ except ImportError: | |||
13 | import bb.server.xmlrpc | 13 | import bb.server.xmlrpc |
14 | import prserv | 14 | import prserv |
15 | import prserv.db | 15 | import prserv.db |
16 | import errno | ||
16 | 17 | ||
17 | logger = logging.getLogger("BitBake.PRserv") | 18 | logger = logging.getLogger("BitBake.PRserv") |
18 | 19 | ||
@@ -280,8 +281,18 @@ def stop_daemon(host, port): | |||
280 | if pid: | 281 | if pid: |
281 | if os.path.exists(pidfile): | 282 | if os.path.exists(pidfile): |
282 | os.remove(pidfile) | 283 | os.remove(pidfile) |
283 | os.kill(pid,signal.SIGTERM) | 284 | |
284 | time.sleep(0.1) | 285 | wait_timeout = 0 |
286 | while is_running(pid) and wait_timeout < 10: | ||
287 | print("Waiting for pr-server to exit.") | ||
288 | time.sleep(0.5) | ||
289 | wait_timeout += 1 | ||
290 | |||
291 | if is_running(pid): | ||
292 | print("Sending SIGTERM to pr-server.") | ||
293 | os.kill(pid,signal.SIGTERM) | ||
294 | time.sleep(0.1) | ||
295 | |||
285 | except OSError as e: | 296 | except OSError as e: |
286 | err = str(e) | 297 | err = str(e) |
287 | if err.find("No such process") <= 0: | 298 | if err.find("No such process") <= 0: |
@@ -289,6 +300,14 @@ def stop_daemon(host, port): | |||
289 | 300 | ||
290 | return 0 | 301 | return 0 |
291 | 302 | ||
303 | def is_running(pid): | ||
304 | try: | ||
305 | os.kill(pid, 0) | ||
306 | except OSError as err: | ||
307 | if err.errno == errno.ESRCH: | ||
308 | return False | ||
309 | return True | ||
310 | |||
292 | def is_local_special(host, port): | 311 | def is_local_special(host, port): |
293 | if host.strip().upper() == 'localhost'.upper() and (not port): | 312 | if host.strip().upper() == 'localhost'.upper() and (not port): |
294 | return True | 313 | return True |