mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-23 14:37:17 +00:00
fix: Added a backoff time if an IOError happens
This commit is contained in:
parent
9a66a6111b
commit
3e117195a2
1 changed files with 7 additions and 1 deletions
|
@ -42,6 +42,8 @@ else:
|
||||||
zmq_url = "tcp://127.0.0.1:5556"
|
zmq_url = "tcp://127.0.0.1:5556"
|
||||||
|
|
||||||
pystemonpath = cfg.get("Directories", "pystemonpath")
|
pystemonpath = cfg.get("Directories", "pystemonpath")
|
||||||
|
base_sleeptime = 0.01
|
||||||
|
sleep_inc = 0
|
||||||
|
|
||||||
context = zmq.Context()
|
context = zmq.Context()
|
||||||
socket = context.socket(zmq.PUB)
|
socket = context.socket(zmq.PUB)
|
||||||
|
@ -54,7 +56,7 @@ r = redis.StrictRedis(host='localhost', db=10)
|
||||||
# 102 raw pastes feed
|
# 102 raw pastes feed
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(1)
|
time.sleep(base_sleeptime + sleep_inc)
|
||||||
topic = 101
|
topic = 101
|
||||||
paste = r.lpop("pastes")
|
paste = r.lpop("pastes")
|
||||||
if paste is None:
|
if paste is None:
|
||||||
|
@ -64,5 +66,9 @@ while True:
|
||||||
try:
|
try:
|
||||||
messagedata = open(pystemonpath+paste).read()
|
messagedata = open(pystemonpath+paste).read()
|
||||||
socket.send("%d %s %s" % (topic, paste, base64.b64encode(messagedata)))
|
socket.send("%d %s %s" % (topic, paste, base64.b64encode(messagedata)))
|
||||||
|
sleep_inc = sleep_inc-0.01 if sleep_inc-0.01 > 0 else 0
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
|
# file not found, could be a buffering issue -> increase sleeping time
|
||||||
|
print('IOError: Increasing sleep time')
|
||||||
|
sleep_inc += 0.5
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue