Skip to content

Commit 16cce72

Browse files
committed
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 <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
1 parent 0257209 commit 16cce72

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/qemu/aqmp/events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ async def get(self) -> Message:
556556
"""
557557
return await self._queue.get()
558558

559+
def empty(self) -> bool:
560+
"""
561+
Return `True` if there are no pending events.
562+
"""
563+
return self._queue.empty()
564+
559565
def clear(self) -> None:
560566
"""
561567
Clear this listener of all pending events.

0 commit comments

Comments
 (0)