qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v4 05/15] qemu-iotests: delay QMP socket timers


From: Emanuele Giuseppe Esposito
Subject: Re: [PATCH v4 05/15] qemu-iotests: delay QMP socket timers
Date: Thu, 3 Jun 2021 14:52:51 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1



On 03/06/2021 14:25, Vladimir Sementsov-Ogievskiy wrote:
03.06.2021 14:03, Emanuele Giuseppe Esposito wrote:


So, you just make the class do nothing.. I'd prefer something like this:

@contextmanager
def NoTimeout:
    yield

if qemu_gdb:
   Timeout = NoTimeout

I am not sure I understand what you want to do here.
I have a basic understanding of @contextmanager, but can you explain more what you want to do?

With qemu_gdb you make the class do absolutely nothing. So, it's just provides an interface of context manager, but does nothing.

@contextmanager
def NoTimeout:
    yield

is the same thing: it's context manager, so you can do

with NoTimeout():
   ....

but that context manager does absolutely nothing.


@contextmanager gives you a simple way to create a context manager. You define a function which has yield point. So, everything before yield is __enter__, everything after yield is __exit__. And you can return a value by yield, it will be a return value of __enter__.


So, what I meant: keep Timeout class as is and just add code that I suggested after it.

Oh okay. I didn't know Timeout = NoTimeout was possible (and I didn't know where to put it anyways). Looks cleaner than the normal ifs, will apply this change and send v5.

Thank you,
Emanuele




reply via email to

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