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>
This commit is contained in:
parent
2354250a95
commit
e15893adf9
|
@ -13,6 +13,7 @@ except ImportError:
|
||||||
import bb.server.xmlrpc
|
import bb.server.xmlrpc
|
||||||
import prserv
|
import prserv
|
||||||
import prserv.db
|
import prserv.db
|
||||||
|
import errno
|
||||||
|
|
||||||
logger = logging.getLogger("BitBake.PRserv")
|
logger = logging.getLogger("BitBake.PRserv")
|
||||||
|
|
||||||
|
@ -280,8 +281,18 @@ def stop_daemon(host, port):
|
||||||
if pid:
|
if pid:
|
||||||
if os.path.exists(pidfile):
|
if os.path.exists(pidfile):
|
||||||
os.remove(pidfile)
|
os.remove(pidfile)
|
||||||
os.kill(pid,signal.SIGTERM)
|
|
||||||
time.sleep(0.1)
|
wait_timeout = 0
|
||||||
|
while is_running(pid) and wait_timeout < 10:
|
||||||
|
print("Waiting for pr-server to exit.")
|
||||||
|
time.sleep(0.5)
|
||||||
|
wait_timeout += 1
|
||||||
|
|
||||||
|
if is_running(pid):
|
||||||
|
print("Sending SIGTERM to pr-server.")
|
||||||
|
os.kill(pid,signal.SIGTERM)
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
err = str(e)
|
err = str(e)
|
||||||
if err.find("No such process") <= 0:
|
if err.find("No such process") <= 0:
|
||||||
|
@ -289,6 +300,14 @@ def stop_daemon(host, port):
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def is_running(pid):
|
||||||
|
try:
|
||||||
|
os.kill(pid, 0)
|
||||||
|
except OSError as err:
|
||||||
|
if err.errno == errno.ESRCH:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def is_local_special(host, port):
|
def is_local_special(host, port):
|
||||||
if host.strip().upper() == 'localhost'.upper() and (not port):
|
if host.strip().upper() == 'localhost'.upper() and (not port):
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue