stream reads every 1s, even if nothing, so pop can occur regularly

master
Bel LaPointe 2022-04-11 07:28:19 -06:00
parent ee46eb9897
commit 5049d97a24
2 changed files with 23 additions and 11 deletions

View File

@ -27,15 +27,27 @@ def with_(N, R, T, p):
bucket = Bucket(N, R, T, cb.cb())
while readline():
while True:
got = readline()
if got:
bucket.push()
else:
bucket.pop()
def readline():
def __input(*args):
return input()
def _input(*args):
try:
line = input()
return True
except EOFError:
return False
foo = __input()
except Exception as e:
foo = None
return foo
timeout = 1
signal.signal(signal.SIGALRM, __input)
signal.alarm(timeout)
foo = _input()
return not foo is None
class Bucket:
def __init__(self, N, R, T, CB):