From: Eduardo Habkost <ehabkost@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Daniel Berrange <berrange@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager
Date: Fri, 25 Aug 2017 09:44:50 -0300 [thread overview]
Message-ID: <20170825124450.GD15315@localhost.localdomain> (raw)
In-Reply-To: <20170824072202.26818-2-stefanha@redhat.com>
On Thu, Aug 24, 2017 at 08:22:00AM +0100, Stefan Hajnoczi wrote:
> There are a number of ways to ensure that the QEMU process is shut down
> when the test ends, including atexit.register(), try: finally:, or
> unittest.teardown() methods. All of these require extra code and the
> programmer must remember to add vm.shutdown().
>
> A nice solution is context managers:
>
> with VM(binary) as vm:
> ...
> # vm is guaranteed to be shut down here
>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
--
Eduardo
next prev parent reply other threads:[~2017-08-25 12:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 7:21 [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers Stefan Hajnoczi
2017-08-24 7:22 ` [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager Stefan Hajnoczi
2017-08-25 12:44 ` Eduardo Habkost [this message]
2017-08-24 7:22 ` [Qemu-devel] [PATCH 2/3] iotests.py: add FilePath " Stefan Hajnoczi
2017-08-24 7:22 ` [Qemu-devel] [PATCH 3/3] qemu-iotests: use context managers for resource cleanup in 194 Stefan Hajnoczi
2017-08-24 8:38 ` [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers Fam Zheng
2017-08-24 18:04 ` Stefan Hajnoczi
2017-08-25 7:32 ` Fam Zheng
2017-08-25 8:52 ` Stefan Hajnoczi
2017-08-25 9:29 ` Fam Zheng
2017-08-30 12:44 ` Stefan Hajnoczi
2017-08-30 12:54 ` Fam Zheng
2017-08-28 10:55 ` Markus Armbruster
2017-08-31 11:26 ` Stefan Hajnoczi
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=20170825124450.GD15315@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=berrange@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).