""" Here we have turned was was a synchronous call into an async call with the use of the select module. select is old however and OSs have newer system calls. Asyncio abstracts the system calls out, and gives us primitives to build better async code. """ import select import socket s = socket.create_connection(("httpbin.org", 80)) s.send(b"GET /delay/5 HTTP/1.1\r\nHost: httpbin.org\r\n\r\n") s.setblocking(False) while True: ready_to_read, ready_to_write, in_error = select.select([s], [], []) if s in ready_to_read: buf = s.recv(1024) print(buf) break