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

Method create_unix_connection

Lib/asyncio/unix_events.py:222–270  ·  view source on GitHub ↗
(
            self, protocol_factory, path=None, *,
            ssl=None, sock=None,
            server_hostname=None,
            ssl_handshake_timeout=None,
            ssl_shutdown_timeout=None)

Source from the content-addressed store, hash-verified

220 self.call_soon_threadsafe(transp._process_exited, returncode)
221
222 async def create_unix_connection(
223 self, protocol_factory, path=None, *,
224 ssl=None, sock=None,
225 server_hostname=None,
226 ssl_handshake_timeout=None,
227 ssl_shutdown_timeout=None):
228 assert server_hostname is None or isinstance(server_hostname, str)
229 if ssl:
230 if server_hostname is None:
231 raise ValueError(
232 'you have to pass server_hostname when using ssl')
233 else:
234 if server_hostname is not None:
235 raise ValueError('server_hostname is only meaningful with ssl')
236 if ssl_handshake_timeout is not None:
237 raise ValueError(
238 'ssl_handshake_timeout is only meaningful with ssl')
239 if ssl_shutdown_timeout is not None:
240 raise ValueError(
241 'ssl_shutdown_timeout is only meaningful with ssl')
242
243 if path is not None:
244 if sock is not None:
245 raise ValueError(
246 'path and sock can not be specified at the same time')
247
248 path = os.fspath(path)
249 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
250 try:
251 sock.setblocking(False)
252 await self.sock_connect(sock, path)
253 except:
254 sock.close()
255 raise
256
257 else:
258 if sock is None:
259 raise ValueError('no path and sock were specified')
260 if (sock.family != socket.AF_UNIX or
261 sock.type != socket.SOCK_STREAM):
262 raise ValueError(
263 f'A UNIX Domain Stream Socket was expected, got {sock!r}')
264 sock.setblocking(False)
265
266 transport, protocol = await self._create_connection_transport(
267 sock, protocol_factory, ssl, server_hostname,
268 ssl_handshake_timeout=ssl_handshake_timeout,
269 ssl_shutdown_timeout=ssl_shutdown_timeout)
270 return transport, protocol
271
272 async def create_unix_server(
273 self, protocol_factory, path=None, *,

Callers

nothing calls this directly

Calls 5

socketMethod · 0.80
setblockingMethod · 0.45
sock_connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected