MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / data_received

Method data_received

asyncpg/connect_utils.py:926–942  ·  view source on GitHub ↗
(self, data: bytes)

Source from the content-addressed store, hash-verified

924 self.ssl_is_advisory = ssl_is_advisory
925
926 def data_received(self, data: bytes) -> None:
927 if data == b'S':
928 self.on_data.set_result(True)
929 elif (self.ssl_is_advisory and
930 self.ssl_context.verify_mode == ssl_module.CERT_NONE and
931 data == b'N'):
932 # ssl_is_advisory will imply that ssl.verify_mode == CERT_NONE,
933 # since the only way to get ssl_is_advisory is from
934 # sslmode=prefer. But be extra sure to disallow insecure
935 # connections when the ssl context asks for real security.
936 self.on_data.set_result(False)
937 else:
938 self.on_data.set_exception(
939 ConnectionError(
940 'PostgreSQL server at "{host}:{port}" '
941 'rejected SSL upgrade'.format(
942 host=self.host, port=self.port)))
943
944 def connection_lost(self, exc: typing.Optional[Exception]) -> None:
945 if not self.on_data.done():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected