[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v4 18/20] iotests: add QMP event waiting queue
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-block] [PATCH v4 18/20] iotests: add QMP event waiting queue |
Date: |
Thu, 2 Apr 2015 14:57:52 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Fri, Mar 20, 2015 at 03:17:01PM -0400, John Snow wrote:
> +# Test if 'match' is a recursive subset of 'event'
> +def event_match(event, match = None):
Not worth respinning but PEP8 says there should be no spaces around the
'=' for keyword arguments:
https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements
> + def event_wait(self, name='BLOCK_JOB_COMPLETED', maxtries=3, match=None):
> + # Search cached events
> + for event in self._events:
> + if (event['event'] == name) and event_match(event, match):
> + self._events.remove(event)
> + return event
> +
> + # Poll for new events
> + for _ in range(maxtries):
> + event = self._qmp.pull_event(wait=True)
> + if (event['event'] == name) and event_match(event, match):
> + return event
> + self._events.append(event)
> +
> + return None
I'm not sure if maxtries is useful. Why is a particular number of
skipped events useful to the caller and how do they pick the magic
number?
If you added the argument because this is a blocking operation then we
should probably use timeouts instead. Timeouts will bail out even if
QEMU is unresponsive.
pgpcyir1kbtz6.pgp
Description: PGP signature
- Re: [Qemu-block] [PATCH v4 18/20] iotests: add QMP event waiting queue,
Stefan Hajnoczi <=