Multi-threading with a simple timer?

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Jul 4 04:35:09 EDT 2018


Another way on unix that doesn't use signals:

import select, sys

print("Enter something: ", end = "")
sys.stdout.flush()
fds = select.select((0,), (), (), 5)
if fds[0] == [0]:
     data = sys.stdin.readline()
     print("You entered:", data)
else:
     print("Too late!")

-- 
Greg


More information about the Python-list mailing list