Received: from eggs.gnu.org ([2001:4830:134:3::10]:39569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdfdE-0002UY-1q for qemu-devel@nongnu.org; Thu, 02 Apr 2015 09:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdfdD-0001uE-3L for qemu-devel@nongnu.org; Thu, 02 Apr 2015 09:58:04 -0400 Date: Thu, 2 Apr 2015 14:57:52 +0100 From: Stefan Hajnoczi Message-ID: <20150402135752.GM25244@stefanha-thinkpad.redhat.com> References: <1426879023-18151-1-git-send-email-jsnow@redhat.com> <1426879023-18151-19-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1hVIwB4NpNcOOTEe" Content-Disposition: inline In-Reply-To: <1426879023-18151-19-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v4 18/20] iotests: add QMP event waiting queue List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com, mreitz@redhat.com --1hVIwB4NpNcOOTEe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --1hVIwB4NpNcOOTEe Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVHUrgAAoJEJykq7OBq3PIuosH/2UV2MQzVwhnsfF2qKLFjkZy gLy/wG8A6vU8rdGzlxVBPZl8AXIwckoWW5kn46cK70uo4pYLu6faDYDCAG/pIIPr GPS6oj/ZygGWthNpGN4srNXT/KP7r39jYQgNWvFY9vKlzENBsGL+mIfVx626xBfI 37cJsjcbtdVFoT5UBYo56RRJppN1Li2ZbfpZ5mKoCNyyjWgzJkR4sOAE0u/yDTxj G/Im9mAjm1vhQjTak6zrQ9OSrK9gHzeE9W1XHIPsDm30HNDCI/NiEHkQXcyxQo0u hqffH4zKqU0z25YzGXafXexYXNzfJdk51dH88dD9EGX+1oN4JtQ6jr9HrqatroM= =514L -----END PGP SIGNATURE----- --1hVIwB4NpNcOOTEe--