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

Method echo_server

Lib/test/test_socket.py:7398–7414  ·  view source on GitHub ↗
(self, sock)

Source from the content-addressed store, hash-verified

7396 timeout = support.LOOPBACK_TIMEOUT
7397
7398 def echo_server(self, sock):
7399 def run(sock):
7400 with sock:
7401 conn, _ = sock.accept()
7402 with conn:
7403 event.wait(self.timeout)
7404 msg = conn.recv(1024)
7405 if not msg:
7406 return
7407 conn.sendall(msg)
7408
7409 event = threading.Event()
7410 sock.settimeout(self.timeout)
7411 thread = threading.Thread(target=run, args=(sock, ))
7412 thread.start()
7413 self.addCleanup(thread.join, self.timeout)
7414 event.set()
7415
7416 def echo_client(self, addr, family):
7417 with socket.socket(family=family) as sock:

Callers 4

test_tcp4Method · 0.95
test_tcp6Method · 0.95

Calls 5

startMethod · 0.95
setMethod · 0.95
EventMethod · 0.80
addCleanupMethod · 0.80
settimeoutMethod · 0.45

Tested by

no test coverage detected