MCPcopy Index your code
hub / github.com/dabeaz/python-cookbook / test

Function test

src/12/storing_thread_specific_state/example2.py:22–45  ·  view source on GitHub ↗
(conn)

Source from the content-addressed store, hash-verified

20 self.local.connections.pop().close()
21
22def test(conn):
23 # Example use
24 from functools import partial
25
26 with conn as s:
27 s.send(b'GET /index.html HTTP/1.0\r\n')
28 s.send(b'Host: www.python.org\r\n')
29 s.send(b'\r\n')
30 resp = b''.join(iter(partial(s.recv, 8192), b''))
31
32 print('Got {} bytes'.format(len(resp)))
33
34 with conn as s1, conn as s2:
35 s1.send(b'GET /downloads HTTP/1.0\r\n')
36 s2.send(b'GET /index.html HTTP/1.0\r\n')
37 s1.send(b'Host: www.python.org\r\n')
38 s2.send(b'Host: www.python.org\r\n')
39 s1.send(b'\r\n')
40 s2.send(b'\r\n')
41 resp1 = b''.join(iter(partial(s1.recv, 8192), b''))
42 resp2 = b''.join(iter(partial(s2.recv, 8192), b''))
43
44 print('resp1 got {} bytes'.format(len(resp1)))
45 print('resp2 got {} bytes'.format(len(resp2)))
46
47if __name__ == '__main__':
48

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected