Fix performance regression in debug logging from win32 protobuf crash workaround (#940)

This commit is contained in:
J. Nick Koston 2024-08-29 11:37:11 -10:00 committed by GitHub
parent 059af0e000
commit fce8922aa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -12,6 +12,7 @@ cdef float KEEP_ALIVE_TIMEOUT_RATIO
cdef object HANDSHAKE_TIMEOUT
cdef bint TYPE_CHECKING
cdef bint _WIN32
cdef object WRITE_EXCEPTIONS

View File

@ -101,6 +101,7 @@ TCP_CONNECT_TIMEOUT = 60.0
WRITE_EXCEPTIONS = (RuntimeError, ConnectionResetError, OSError)
_WIN32 = sys.platform == "win32"
_int = int
_bytes = bytes
@ -719,7 +720,7 @@ class APIConnection:
# calling __str__ on the message may crash on
# Windows systems due to a bug in the protobuf library
# so we call MessageToDict instead
MessageToDict(msg),
MessageToDict(msg) if _WIN32 else msg,
)
if TYPE_CHECKING:
@ -921,7 +922,7 @@ class APIConnection:
# calling __str__ on the message may crash on
# Windows systems due to a bug in the protobuf library
# so we call MessageToDict instead
MessageToDict(msg),
MessageToDict(msg) if _WIN32 else msg,
)
if self._pong_timer is not None: