From 481607c7d35de2bc4d9bec7f4734036fc467f330 Mon Sep 17 00:00:00 2001 From: John Snow Date: Fri, 25 Feb 2022 15:59:46 -0500 Subject: python/aqmp: add start_server() and accept() methods Add start_server() and accept() methods that can be used instead of start_server_and_accept() to allow more fine-grained control over the incoming connection process. (Eagle-eyed reviewers will surely notice that it's a bit weird that "CONNECTING" is a state that's shared between both the start_server() and connect() states. That's absolutely true, and it's very true that checking on the presence of _accepted as an indicator of state is a hack. That's also very certainly true. But ... this keeps client code an awful lot simpler, as it doesn't have to care exactly *how* the connection is being made, just that it *is*. Is it worth disrupting that simplicity in order to provide a better state guard on `accept()`? Hm.) Signed-off-by: John Snow Acked-by: Kevin Wolf Reviewed-by: Daniel P. Berrangé Message-id: 20220225205948.3693480-9-jsnow@redhat.com Signed-off-by: John Snow --- python/tests/protocol.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'python/tests') diff --git a/python/tests/protocol.py b/python/tests/protocol.py index 5e442e1efb..d6849ad306 100644 --- a/python/tests/protocol.py +++ b/python/tests/protocol.py @@ -43,11 +43,18 @@ class NullProtocol(AsyncProtocol[None]): async def _do_start_server(self, address, ssl=None): if self.fake_session: + self._accepted = asyncio.Event() self._set_state(Runstate.CONNECTING) await asyncio.sleep(0) else: await super()._do_start_server(address, ssl) + async def _do_accept(self): + if self.fake_session: + self._accepted = None + else: + await super()._do_accept() + async def _do_connect(self, address, ssl=None): if self.fake_session: self._set_state(Runstate.CONNECTING) -- cgit v1.2.3-55-g7522