This commit is contained in:
J. Nick Koston 2024-02-16 17:39:26 -06:00
parent d1bebcbd03
commit 1b386a3326
No known key found for this signature in database
2 changed files with 24 additions and 25 deletions

View File

@ -154,3 +154,7 @@ cdef class APIConnection:
cdef void _register_internal_message_handlers(self)
cdef void _increase_recv_buffer_size(self)
cdef void _set_start_connect_future(self)
cdef void _set_finish_connect_future(self)

View File

@ -286,19 +286,8 @@ class APIConnection:
fut.set_exception(new_exc)
self._read_exception_futures.clear()
if (
self._start_connect_future is not None
and not self._start_connect_future.done()
):
self._start_connect_future.set_result(None)
self._start_connect_future = None
if (
self._finish_connect_future is not None
and not self._finish_connect_future.done()
):
self._finish_connect_future.set_result(None)
self._finish_connect_future = None
self._set_start_connect_future()
self._set_finish_connect_future()
if self._frame_helper is not None:
self._frame_helper.close()
@ -620,14 +609,17 @@ class APIConnection:
self._cleanup()
raise self._wrap_fatal_connection_exception("starting", ex)
finally:
if (
self._start_connect_future is not None
and not self._start_connect_future.done()
):
self._start_connect_future.set_result(None)
self._start_connect_future = None
self._set_start_connect_future()
self._set_connection_state(CONNECTION_STATE_SOCKET_OPENED)
def _set_start_connect_future(self) -> None:
if (
self._start_connect_future is not None
and not self._start_connect_future.done()
):
self._start_connect_future.set_result(None)
self._start_connect_future = None
def _wrap_fatal_connection_exception(
self, action: str, ex: BaseException
) -> APIConnectionError:
@ -684,14 +676,17 @@ class APIConnection:
self._cleanup()
raise self._wrap_fatal_connection_exception("finishing", ex)
finally:
if (
self._finish_connect_future is not None
and not self._finish_connect_future.done()
):
self._finish_connect_future.set_result(None)
self._finish_connect_future = None
self._set_finish_connect_future()
self._set_connection_state(CONNECTION_STATE_CONNECTED)
def _set_finish_connect_future(self) -> None:
if (
self._finish_connect_future is not None
and not self._finish_connect_future.done()
):
self._finish_connect_future.set_result(None)
self._finish_connect_future = None
def _set_connection_state(self, state: ConnectionState) -> None:
"""Set the connection state and log the change."""
self.connection_state = state