1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

bitbake: prserv/serv: Use with while reading pidfile

(Bitbake rev: 6fa8a18ea4994031fdd1253fe363c5d8eeeba456)

Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ola x Nilsson
2019-12-20 15:23:19 +01:00
committed by Richard Purdie
parent 99c27e5874
commit 41a0a29c4d
+5 -7
View File
@@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
logger.addHandler(streamhandler) logger.addHandler(streamhandler)
# write pidfile # write pidfile
pid = str(os.getpid()) pid = str(os.getpid())
pf = open(self.pidfile, 'w') with open(self.pidfile, 'w') as pf:
pf.write("%s\n" % pid) pf.write("%s\n" % pid)
pf.close()
self.work_forever() self.work_forever()
self.delpid() self.delpid()
@@ -353,9 +352,8 @@ def start_daemon(dbfile, host, port, logfile):
ip = socket.gethostbyname(host) ip = socket.gethostbyname(host)
pidfile = PIDPREFIX % (ip, port) pidfile = PIDPREFIX % (ip, port)
try: try:
pf = open(pidfile,'r') with open(pidfile) as pf:
pid = int(pf.readline().strip()) pid = int(pf.readline().strip())
pf.close()
except IOError: except IOError:
pid = None pid = None