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

Method get_high_socket_fd

Lib/test/_test_multiprocessing.py:5878–5894  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5876class TestCloseFds(unittest.TestCase):
5877
5878 def get_high_socket_fd(self):
5879 if WIN32:
5880 # The child process will not have any socket handles, so
5881 # calling socket.fromfd() should produce WSAENOTSOCK even
5882 # if there is a handle of the same number.
5883 return socket.socket().detach()
5884 else:
5885 # We want to produce a socket with an fd high enough that a
5886 # freshly created child process will not have any fds as high.
5887 fd = socket.socket().detach()
5888 to_close = []
5889 while fd < 50:
5890 to_close.append(fd)
5891 fd = os.dup(fd)
5892 for x in to_close:
5893 os.close(x)
5894 return fd
5895
5896 def close(self, fd):
5897 if WIN32:

Callers 1

test_closefdMethod · 0.95

Calls 5

socketMethod · 0.80
detachMethod · 0.45
appendMethod · 0.45
dupMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected