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>
This commit is contained in:
parent
0257209a09
commit
16cce725ed
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user