qemu-block
[Top][All Lists]
Advanced

[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: John Snow
Subject: Re: [Qemu-block] [PATCH v4 18/20] iotests: add QMP event waiting queue
Date: Thu, 02 Apr 2015 13:19:22 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0



On 04/02/2015 09:57 AM, Stefan Hajnoczi wrote:
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.


Yeah, this was just a poor man's timeout.

I'll make it nicer.



reply via email to

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