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.
pgp_sNeWrvfp1.pgp
Description: PGP signature