MCPcopy
hub / github.com/pyodide/pyodide / test_socket_recv_after_close

Function test_socket_recv_after_close

src/tests/test_python_socket.py:240–262  ·  view source on GitHub ↗

Test receiving data after server closes connection.

(selenium_nodesock)

Source from the content-addressed store, hash-verified

238
239
240def test_socket_recv_after_close(selenium_nodesock):
241 """Test receiving data after server closes connection."""
242
243 def handler(conn, _addr):
244 conn.sendall(b"Final message")
245
246 @run_in_pyodide
247 def run(selenium, host, port):
248 import socket
249 import time
250
251 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
252 s.connect((host, port))
253
254 time.sleep(0.5)
255
256 data = s.recv(1024)
257 s.close()
258 return data.decode()
259
260 with tcp_server(handler) as (host, port):
261 result = run(selenium_nodesock, host, port)
262 assert result == "Final message"
263
264
265def test_socket_fileno(selenium_nodesock):

Callers

nothing calls this directly

Calls 2

tcp_serverFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…