diff options
| author | Ola x Nilsson <ola.x.nilsson@axis.com> | 2019-12-20 15:23:19 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-11 11:06:22 +0000 |
| commit | 9b0f2f2e79c72855e654765d9c072109eed3d1e9 (patch) | |
| tree | 6013c6da9c1a5d23ce5cbd6cdec865005359c8d7 /bitbake/lib | |
| parent | f619b134039765e86bc0dec86485953b623ee89f (diff) | |
| download | poky-9b0f2f2e79c72855e654765d9c072109eed3d1e9.tar.gz | |
bitbake: prserv/serv: Use with while reading pidfile
(Bitbake rev: e731f72ca86629eb935bb1c4f7323421a125aace)
Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 6fa8a18ea4994031fdd1253fe363c5d8eeeba456)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/prserv/serv.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py index 6d8142fcc4..446e1fe127 100644 --- a/bitbake/lib/prserv/serv.py +++ b/bitbake/lib/prserv/serv.py | |||
| @@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer): | |||
| 292 | logger.addHandler(streamhandler) | 292 | logger.addHandler(streamhandler) |
| 293 | 293 | ||
| 294 | # write pidfile | 294 | # write pidfile |
| 295 | pid = str(os.getpid()) | 295 | pid = str(os.getpid()) |
| 296 | pf = open(self.pidfile, 'w') | 296 | with open(self.pidfile, 'w') as pf: |
| 297 | pf.write("%s\n" % pid) | 297 | pf.write("%s\n" % pid) |
| 298 | pf.close() | ||
| 299 | 298 | ||
| 300 | self.work_forever() | 299 | self.work_forever() |
| 301 | self.delpid() | 300 | self.delpid() |
| @@ -353,9 +352,8 @@ def start_daemon(dbfile, host, port, logfile): | |||
| 353 | ip = socket.gethostbyname(host) | 352 | ip = socket.gethostbyname(host) |
| 354 | pidfile = PIDPREFIX % (ip, port) | 353 | pidfile = PIDPREFIX % (ip, port) |
| 355 | try: | 354 | try: |
| 356 | pf = open(pidfile,'r') | 355 | with open(pidfile) as pf: |
| 357 | pid = int(pf.readline().strip()) | 356 | pid = int(pf.readline().strip()) |
| 358 | pf.close() | ||
| 359 | except IOError: | 357 | except IOError: |
| 360 | pid = None | 358 | pid = None |
| 361 | 359 | ||
