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

Method _sock_connect

Lib/asyncio/selector_events.py:653–674  ·  view source on GitHub ↗
(self, fut, sock, address)

Source from the content-addressed store, hash-verified

651 fut = None
652
653 def _sock_connect(self, fut, sock, address):
654 fd = sock.fileno()
655 try:
656 sock.connect(address)
657 except (BlockingIOError, InterruptedError):
658 # Issue #23618: When the C function connect() fails with EINTR, the
659 # connection runs in background. We have to wait until the socket
660 # becomes writable to be notified when the connection succeed or
661 # fails.
662 self._ensure_fd_no_transport(fd)
663 handle = self._add_writer(
664 fd, self._sock_connect_cb, fut, sock, address)
665 fut.add_done_callback(
666 functools.partial(self._sock_write_done, fd, handle=handle))
667 except (SystemExit, KeyboardInterrupt):
668 raise
669 except BaseException as exc:
670 fut.set_exception(exc)
671 else:
672 fut.set_result(None)
673 finally:
674 fut = None
675
676 def _sock_write_done(self, fd, fut, handle=None):
677 if handle is None or not handle.cancelled():

Callers 1

sock_connectMethod · 0.95

Calls 8

_add_writerMethod · 0.95
partialMethod · 0.80
filenoMethod · 0.45
connectMethod · 0.45
add_done_callbackMethod · 0.45
set_exceptionMethod · 0.45
set_resultMethod · 0.45

Tested by

no test coverage detected