All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Richard Purdie <richard.purdie@linuxfoundation.org>,
	Ola x Nilsson <Ola.x.Nilsson@axis.com>,
	"bitbake-devel@lists.openembedded.org"
	<bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH 1/2] bitbake: prserv/serv: Use with while	reading pidfile
Date: Mon, 30 Dec 2019 12:20:18 +0000	[thread overview]
Message-ID: <6a86529855cc4276944551773f09e266@XBOX03.axis.com> (raw)
In-Reply-To: <d7d728082189ea9cde744cac1ab40b9bb11cd64e.camel@linuxfoundation.org>

> -----Original Message-----
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
> Sent: den 30 december 2019 12:00
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; Ola x Nilsson
> <Ola.x.Nilsson@axis.com>; bitbake-devel@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@lists.openembedded.org <bitbake-devel-
> > > bounces@lists.openembedded.org> On Behalf Of Ola x Nilsson
> > > Sent: den 20 december 2019 15:23
> > > To: bitbake-devel@lists.openembedded.org
> > > Subject: [bitbake-devel] [PATCH 1/2] bitbake: prserv/serv: Use with
> > > while
> > > reading pidfile
> > >
> > > 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
> >
> > 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


  reply	other threads:[~2019-12-30 12:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 14:23 [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Ola x Nilsson
2019-12-20 14:23 ` [PATCH 2/2] bitbake-layers: Keep loglevel in colored logger Ola x Nilsson
2019-12-20 17:22 ` [PATCH 1/2] bitbake: prserv/serv: Use with while reading pidfile Peter Kjellerstedt
2019-12-30 11:00   ` Richard Purdie
2019-12-30 12:20     ` Peter Kjellerstedt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-10-21  9:07 Ola x Nilsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a86529855cc4276944551773f09e266@XBOX03.axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=Ola.x.Nilsson@axis.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.