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

Function test

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

Source from the content-addressed store, hash-verified

20 del self.local.sock
21
22def test(conn):
23 from functools import partial
24
25 # Connection closed
26 with conn as s:
27 # conn.__enter__() executes: connection open
28 s.send(b'GET /index.html HTTP/1.0\r\n')
29 s.send(b'Host: www.python.org\r\n')
30 s.send(b'\r\n')
31 resp = b''.join(iter(partial(s.recv, 8192), b''))
32 # conn.__exit__() executes: connection closed
33
34 print('Got {} bytes'.format(len(resp)))
35
36if __name__ == '__main__':
37 conn = LazyConnection(('www.python.org', 80))

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected