Created
September 19, 2018 11:57
-
-
Save wolph/285a1c8dba739995a385c887cbb5af98 to your computer and use it in GitHub Desktop.
Read all available data from file handle and return (with optional timeout)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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