MCPcopy Create free account
hub / github.com/EasyIME/PIME / _handle_connect

Method _handle_connect

python/python3/tornado/iostream.py:1505–1531  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1503 return self.wait_for_handshake()
1504
1505 def _handle_connect(self) -> None:
1506 # Call the superclass method to check for errors.
1507 super()._handle_connect()
1508 if self.closed():
1509 return
1510 # When the connection is complete, wrap the socket for SSL
1511 # traffic. Note that we do this by overriding _handle_connect
1512 # instead of by passing a callback to super().connect because
1513 # user callbacks are enqueued asynchronously on the IOLoop,
1514 # but since _handle_events calls _handle_connect immediately
1515 # followed by _handle_write we need this to be synchronous.
1516 #
1517 # The IOLoop will get confused if we swap out self.socket while the
1518 # fd is registered, so remove it now and re-register after
1519 # wrap_socket().
1520 self.io_loop.remove_handler(self.socket)
1521 old_state = self._state
1522 assert old_state is not None
1523 self._state = None
1524 self.socket = ssl_wrap_socket(
1525 self.socket,
1526 self._ssl_options,
1527 server_hostname=self._server_hostname,
1528 do_handshake_on_connect=False,
1529 server_side=False,
1530 )
1531 self._add_io_state(old_state)
1532
1533 def wait_for_handshake(self) -> "Future[SSLIOStream]":
1534 """Wait for the initial SSL handshake to complete.

Callers

nothing calls this directly

Calls 5

ssl_wrap_socketFunction · 0.90
closedMethod · 0.80
_add_io_stateMethod · 0.80
_handle_connectMethod · 0.45
remove_handlerMethod · 0.45

Tested by

no test coverage detected