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.
Alternatively, I send the patch as-is, and then you can send this change.
OK for me.
Thank you,
Emanuele
anyway:
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
--
Best regards,
Vladimir