MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_high_socket_fd

Method get_high_socket_fd

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

Source from the content-addressed store, hash-verified

5543class TestCloseFds(unittest.TestCase):
5544
5545 def get_high_socket_fd(self):
5546 if WIN32:
5547 # The child process will not have any socket handles, so
5548 # calling socket.fromfd() should produce WSAENOTSOCK even
5549 # if there is a handle of the same number.
5550 return socket.socket().detach()
5551 else:
5552 # We want to produce a socket with an fd high enough that a
5553 # freshly created child process will not have any fds as high.
5554 fd = socket.socket().detach()
5555 to_close = []
5556 while fd < 50:
5557 to_close.append(fd)
5558 fd = os.dup(fd)
5559 for x in to_close:
5560 os.close(x)
5561 return fd
5562
5563 def close(self, fd):
5564 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