diff options
| author | Stefan Hajnoczi | 2017-08-24 09:22:00 +0200 |
|---|---|---|
| committer | Stefan Hajnoczi | 2017-09-05 11:32:06 +0200 |
| commit | d792bc3811f22a22a46c7d9a725fd29029f54095 (patch) | |
| tree | 050d6c420bae261d0909575b340dc37bf1fac2f9 /scripts/git.orderfile | |
| parent | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170904-... (diff) | |
| download | qemu-d792bc3811f22a22a46c7d9a725fd29029f54095.tar.gz qemu-d792bc3811f22a22a46c7d9a725fd29029f54095.tar.xz qemu-d792bc3811f22a22a46c7d9a725fd29029f54095.zip | |
qemu.py: make VM() a context manager
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>
Message-id: 20170824072202.26818-2-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts/git.orderfile')
0 files changed, 0 insertions, 0 deletions
