From 405a9068ce5072050b9878f7cec15b2c2592bc4e Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 21 Oct 2019 11:07:04 +0200 Subject: bitbake: prserv/serv: Use with while reading pidfile Signed-off-by: Ola x Nilsson Signed-off-by: Richard Purdie --- lib/prserv/serv.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py index be3acec36..2bc68904f 100644 --- a/lib/prserv/serv.py +++ b/lib/prserv/serv.py @@ -379,9 +379,8 @@ def stop_daemon(host, port): ip = socket.gethostbyname(host) pidfile = PIDPREFIX % (ip, port) try: - pf = open(pidfile,'r') - pid = int(pf.readline().strip()) - pf.close() + with open(pidfile) as pf: + pid = int(pf.readline().strip()) except IOError: pid = None -- cgit 1.2.3-korg