qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Roman Kagan <rkagan@virtuozzo.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
	Denis Lunev <den@virtuozzo.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Subject: Re: [PATCH v3] iotests: Test NBD client reconnection
Date: Fri, 8 Nov 2019 14:05:31 +0000	[thread overview]
Message-ID: <20191108140527.GA63895@rkaganb.sw.ru> (raw)
In-Reply-To: <feb2b810-3436-6550-43b2-a07ec1fc5280@virtuozzo.com>

On Fri, Nov 08, 2019 at 01:49:50PM +0000, Vladimir Sementsov-Ogievskiy wrote:
> 01.11.2019 19:54, Andrey Shinkevich wrote:
> > +def check_proc_NBD(proc, connector):
> > +    try:
> > +        exitcode = proc.wait(timeout=10)
> > +
> > +        if exitcode < 0:
> > +            log('NBD {}: EXIT SIGNAL {}\n'.format(connector, -exitcode))
> > +            log(proc.communicate()[0])
> > +        else:
> > +            line = proc.stdout.readline()
> 
> 
> could we use proc.communicate() for both cases, what is the difference?

In fact if proc produces any non-trivial amount of output you are better
off using .communicate() otherwise your child may block on output and
never exit.  See
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate
for how to express the above logic correctly.  The exit code *after*
.communicate is available in .returncode.

> 
> > +            log('NBD {}: {}'.format(connector, line.rstrip()))
> > +
> > +    except subprocess.TimeoutExpired:
> > +        proc.kill()
> > +        log('NBD {}: ERROR timeout expired'.format(connector))
> > +    finally:
> > +        if connector == 'server':
> > +            os.remove(nbd_sock)
> > +            os.remove(conf_file)

Roman.


  reply	other threads:[~2019-11-08 14:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 16:54 [PATCH v3] iotests: Test NBD client reconnection Andrey Shinkevich
2019-11-08 13:49 ` Vladimir Sementsov-Ogievskiy
2019-11-08 14:05   ` Roman Kagan [this message]
2019-11-11  9:18     ` Andrey Shinkevich
2019-11-11  9:48       ` Roman Kagan
2019-11-11  9:07   ` Andrey Shinkevich

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=20191108140527.GA63895@rkaganb.sw.ru \
    --to=rkagan@virtuozzo.com \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=den@virtuozzo.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).