diff options
author | John Snow <jsnow@redhat.com> | 2021-09-22 20:49:23 -0400 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2021-10-12 12:22:10 -0400 |
commit | 16cce725ed87e3ed5901c93e61514840c989216a (patch) | |
tree | de1bd17e5a00b27115166697e27e547fcb4771b0 /python | |
parent | 0257209a09793bfaf1b662faad5558e7011e748a (diff) |
python/aqmp: add .empty() method to EventListener
Synchronous clients may want to know if they're about to block waiting
for an event or not. A method such as this is necessary to implement a
compatible interface for the old QEMUMonitorProtocol using the new async
internals.
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20210923004938.3999963-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'python')
-rw-r--r-- | python/qemu/aqmp/events.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/python/qemu/aqmp/events.py b/python/qemu/aqmp/events.py index fb81d21610..271899f6b8 100644 --- a/python/qemu/aqmp/events.py +++ b/python/qemu/aqmp/events.py @@ -556,6 +556,12 @@ class EventListener: """ return await self._queue.get() + def empty(self) -> bool: + """ + Return `True` if there are no pending events. + """ + return self._queue.empty() + def clear(self) -> None: """ Clear this listener of all pending events. |