MCPcopy Index your code
hub / github.com/pyodide/pyodide / test_socket_shutdown_pairs

Function test_socket_shutdown_pairs

src/tests/test_python_socket.py:565–599  ·  view source on GitHub ↗

All 9 combinations of two consecutive shutdown() calls should succeed (Linux behavior).

(selenium_nodesock)

Source from the content-addressed store, hash-verified

563
564
565def test_socket_shutdown_pairs(selenium_nodesock):
566 """All 9 combinations of two consecutive shutdown() calls should succeed (Linux behavior)."""
567
568 server_conns = []
569
570 def handler(conn, _addr):
571 server_conns.append(conn)
572 try:
573 while True:
574 data = conn.recv(1024)
575 if not data:
576 break
577 conn.sendall(data)
578 except OSError:
579 pass
580
581 @run_in_pyodide
582 def run(selenium, host, port, first, second):
583 import socket
584
585 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
586 s.connect((host, port))
587 s.sendall(b"ping")
588 s.recv(1024)
589
590 s.shutdown(first)
591 s.shutdown(second)
592 s.close()
593
594 shut_values = [0, 1, 2]
595 for first in shut_values:
596 for second in shut_values:
597 with tcp_server(handler) as (host, port):
598 run(selenium_nodesock, host, port, first, second)
599 server_conns.clear()
600
601
602def test_socket_nonblocking_recv_with_buffered_data(selenium_nodesock):

Callers

nothing calls this directly

Calls 3

tcp_serverFunction · 0.85
clearMethod · 0.80
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…