vici: Gracefully consume/ignore incoming events in Python event deregistration
When issuing a deregistration message, some last events may still be sent
by the daemon before deregistration completes. Ignore such event messages
silently during deregistration, avoiding exceptions like:
vici.exception.SessionException:
Unexpected response type 7, expected '5' (EVENT_CONFIRM)
This commit is contained in:
committed by
Tobias Brunner
parent
254d4075fe
commit
484c0f8dd0
@@ -84,6 +84,7 @@ class TestSession(object):
|
||||
if name is None:
|
||||
i += 1
|
||||
if i > 2:
|
||||
s.send(Packet.EVENT, name="event", message={"late": b'1'})
|
||||
s.send(Packet.EVENT_CONFIRM)
|
||||
s.send(Packet.EVENT_CONFIRM)
|
||||
break
|
||||
|
||||
@@ -40,7 +40,9 @@ class Session(CommandWrappers, object):
|
||||
raise EventUnknownException(
|
||||
"Unknown event type '{event}'".format(event=event_type)
|
||||
)
|
||||
elif response.response_type != Packet.EVENT_CONFIRM:
|
||||
while response.response_type == Packet.EVENT:
|
||||
response = Packet.parse(self.transport.receive())
|
||||
if response.response_type != Packet.EVENT_CONFIRM:
|
||||
raise SessionException(
|
||||
"Unexpected response type {type}, "
|
||||
"expected '{confirm}' (EVENT_CONFIRM)".format(
|
||||
|
||||
Reference in New Issue
Block a user