Linux python asynchronous input from stdin using select()
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
#Replacing | |
thisChar = sys.stdin.read(1) | |
#With | |
import select | |
try: | |
if select.select([sys.stdin,], [], [], 0)[0]: | |
thisChar = sys.stdin.read(1) | |
else: | |
if (debug): | |
print "nothing to read" | |
except IOError: | |
#nothing to read. should really have checked first | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment