[bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile

Peter Kjellerstedt peter.kjellerstedt at axis.com
Mon Dec 30 12:20:18 UTC 2019


> -----Original Message-----
> From: Richard Purdie <richard.purdie at linuxfoundation.org>
> Sent: den 30 december 2019 12:00
> To: Peter Kjellerstedt <peter.kjellerstedt at axis.com>; Ola x Nilsson
> <Ola.x.Nilsson at axis.com>; bitbake-devel at lists.openembedded.org
> Subject: Re: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> while reading pidfile
> 
> On Fri, 2019-12-20 at 17:22 +0000, Peter Kjellerstedt wrote:
> > > -----Original Message-----
> > > From: bitbake-devel-bounces at lists.openembedded.org <bitbake-devel-
> > > bounces at lists.openembedded.org> On Behalf Of Ola x Nilsson
> > > Sent: den 20 december 2019 15:23
> > > To: bitbake-devel at lists.openembedded.org
> > > Subject: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> > > while
> > > reading pidfile
> > >
> > > Signed-off-by: Ola x Nilsson <olani at 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
> >
> > This only half the patch. Please add the following:
> >
> > @@ -292,10 +292,9 @@ class PRServer(SimpleXMLRPCServer):
> >          logger.addHandler(streamhandler)
> >
> >          # write pidfile
> > -        pid = str(os.getpid())
> > -        pf = open(self.pidfile, 'w')
> > -        pf.write("%s\n" % pid)
> > -        pf.close()
> > +        pid = str(os.getpid())
> > +        with open(self.pidfile, 'w') as pf:
> > +            pf.write("%s\n" % pid)
> >
> >          self.work_forever()
> >          self.delpid()
> >
> 
> I've handled this but asking me to manually merge hunks of patches
> together before applying them seems a little potentially error prone?
> 
> Cheers,
> 
> Richard

Well, I mainly meant for Ola to send an updated patch with both hunks, but 
I guess I should have stated that in my response. Anyway, thanks for taking 
care of it.

//Peter



More information about the bitbake-devel mailing list