All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
@ 2019-10-21  9:07 Ola x Nilsson
  2019-10-21  9:07 ` [PATCH 2/2] bitbake: ConfHandler: Use with to manage filehandle lifetime Ola x Nilsson
  0 siblings, 1 reply; 6+ messages in thread
From: Ola x Nilsson @ 2019-10-21  9:07 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 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 be3acec3..2bc68904 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
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile
@ 2019-12-20 14:23 Ola x Nilsson
  2019-12-20 17:22 ` Peter Kjellerstedt
  0 siblings, 1 reply; 6+ messages in thread
From: Ola x Nilsson @ 2019-12-20 14:23 UTC (permalink / raw)
  To: bitbake-devel

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 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 3124b079..708b2e0a 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -353,9 +353,8 @@ def start_daemon(dbfile, host, port, logfile):
     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
 
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-12-30 12:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21  9:07 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
2019-10-21  9:07 ` [PATCH 2/2] bitbake: ConfHandler: Use with to manage filehandle lifetime Ola x Nilsson
2019-12-20 14:23 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
2019-12-20 17:22 ` Peter Kjellerstedt
2019-12-30 11:00   ` Richard Purdie
2019-12-30 12:20     ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.