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

Method echo_server

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

Source from the content-addressed store, hash-verified

7306 timeout = support.LOOPBACK_TIMEOUT
7307
7308 def echo_server(self, sock):
7309 def run(sock):
7310 with sock:
7311 conn, _ = sock.accept()
7312 with conn:
7313 event.wait(self.timeout)
7314 msg = conn.recv(1024)
7315 if not msg:
7316 return
7317 conn.sendall(msg)
7318
7319 event = threading.Event()
7320 sock.settimeout(self.timeout)
7321 thread = threading.Thread(target=run, args=(sock, ))
7322 thread.start()
7323 self.addCleanup(thread.join, self.timeout)
7324 event.set()
7325
7326 def echo_client(self, addr, family):
7327 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