qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager
Date: Fri, 25 Aug 2017 09:44:50 -0300
User-agent: Mutt/1.8.0 (2017-02-23)

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 <address@hidden>
> Signed-off-by: Stefan Hajnoczi <address@hidden>

Reviewed-by: Eduardo Habkost <address@hidden>

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]