Sleeping a thread blocking stdin
Posted
by Sid
on Stack Overflow
See other posts from Stack Overflow
or by Sid
Published on 2010-05-11T09:01:38Z
Indexed on
2010/05/11
11:24 UTC
Read the original article
Hit count: 163
Hey,
I'm running a function which evaluates commands passed in using stdin and another function which runs a bunch of jobs. I need to make the latter function sleep at regular intervals but that seems to be blocking the stdin. Any advice on how to resolve this would be appreciated.
The source code for the functions is
def runJobs(comps, jobQueue, numRunning, limit, lock):
while len(jobQueue) >= 0:
print(len(jobQueue));
if len(jobQueue) > 0:
comp, tasks = find_computer(comps, 0);
#do something
time.sleep(5);
def manageStdin():
print "Global Stdin Begins Now"
for line in fileinput.input():
try:
print(eval(line));
except Exception, e:
print e;
--Thanks
© Stack Overflow or respective owner