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

Class DupSocket

Lib/multiprocessing/resource_sharer.py:27–40  ·  view source on GitHub ↗

Picklable wrapper for a socket.

Source from the content-addressed store, hash-verified

25 __all__ += ['DupSocket']
26
27 class DupSocket(object):
28 '''Picklable wrapper for a socket.'''
29 def __init__(self, sock):
30 new_sock = sock.dup()
31 def send(conn, pid):
32 share = new_sock.share(pid)
33 conn.send_bytes(share)
34 self._id = _resource_sharer.register(send, new_sock.close)
35
36 def detach(self):
37 '''Get the socket. This should only be called once.'''
38 with _resource_sharer.get_connection(self._id) as conn:
39 share = conn.recv_bytes()
40 return socket.fromshare(share)
41
42else:
43 __all__ += ['DupFd']

Callers 1

_reduce_socketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…