Skip to content

Instantly share code, notes, and snippets.

@wolph
Created September 19, 2018 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolph/285a1c8dba739995a385c887cbb5af98 to your computer and use it in GitHub Desktop.
Save wolph/285a1c8dba739995a385c887cbb5af98 to your computer and use it in GitHub Desktop.
Read all available data from file handle and return (with optional timeout)
def read(fh, timeout=0):
output = []
while select.select([fh], [], [], timeout)[0]:
output.append(fh.read(1))
return ''.join(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment