MCPcopy Index your code
hub / github.com/python/cpython / sock_connect

Method sock_connect

Lib/asyncio/selector_events.py:628–651  ·  view source on GitHub ↗

Connect to a remote socket at address. This method is a coroutine.

(self, sock, address)

Source from the content-addressed store, hash-verified

626 fut.set_result(n)
627
628 async def sock_connect(self, sock, address):
629 """Connect to a remote socket at address.
630
631 This method is a coroutine.
632 """
633 base_events._check_ssl_socket(sock)
634 if self._debug and sock.gettimeout() != 0:
635 raise ValueError("the socket must be non-blocking")
636
637 if sock.family == socket.AF_INET or (
638 base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
639 resolved = await self._ensure_resolved(
640 address, family=sock.family, type=sock.type, proto=sock.proto,
641 loop=self,
642 )
643 _, _, _, _, address = resolved[0]
644
645 fut = self.create_future()
646 self._sock_connect(fut, sock, address)
647 try:
648 return await fut
649 finally:
650 # Needed to break cycles when an exception occurs.
651 fut = None
652
653 def _sock_connect(self, fut, sock, address):
654 fd = sock.fileno()

Callers

nothing calls this directly

Calls 4

_sock_connectMethod · 0.95
_ensure_resolvedMethod · 0.80
gettimeoutMethod · 0.45
create_futureMethod · 0.45

Tested by

no test coverage detected