Small speed up to writing outgoing packets

There were two try blocks to convert exception types.
Simplify by removing one of the try blocks and converting
the exceptions in the connection class
This commit is contained in:
J. Nick Koston 2023-12-04 15:38:44 -10:00
parent 488443c70a
commit d1f6ec04a7
No known key found for this signature in database
3 changed files with 2 additions and 3 deletions

View File

@ -5,7 +5,6 @@ from ..connection cimport APIConnection
cdef bint TYPE_CHECKING
cdef object WRITE_EXCEPTIONS
cdef class APIFrameHelper:

View File

@ -19,7 +19,6 @@ SOCKET_ERRORS = (
TimeoutError,
)
WRITE_EXCEPTIONS = (RuntimeError, ConnectionResetError, OSError)
_int = int
_bytes = bytes

View File

@ -19,7 +19,6 @@ from google.protobuf import message
import aioesphomeapi.host_resolver as hr
from ._frame_helper.base import WRITE_EXCEPTIONS
from ._frame_helper.noise import APINoiseFrameHelper
from ._frame_helper.plain_text import APIPlaintextFrameHelper
from .api_pb2 import ( # type: ignore
@ -97,6 +96,8 @@ CONNECT_REQUEST_TIMEOUT = 30.0
# to reboot and connect to the network/WiFi.
TCP_CONNECT_TIMEOUT = 60.0
WRITE_EXCEPTIONS = (RuntimeError, ConnectionResetError, OSError)
_int = int
_bytes = bytes