Added environment variable and fixed stuff
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2020-03-29 19:18:25 +02:00
parent 48da2c1bb5
commit 2b44a5bbad
2 changed files with 31 additions and 15 deletions

18
app.py
View File

@@ -3,7 +3,7 @@ import sentry_sdk
import communicator
import consumerlocator
import messagesender
import time
"""
Main Flask RESTful API
@@ -27,9 +27,17 @@ if __name__ == "__main__":
print("Producer: started sending")
for i in range(30):
msg = message.createMessage(20)
print("Producer: send ", i, "th message: ", msg)
if not conslist.checkcurrentconsumer():
conslist.updateconsumer()
comm.sendmessage(msg)
print("Producer: trying to send ", i, "th message: ", msg)
available = False
if conslist.updateconsumer() is None:
print("Producer: no consumer available (waiting a bit)")
time.sleep(1)
else:
available = True
if available:
comm.sendmessage(msg)
print("Producer: message sent")
else:
print("Producer: failed to send message")
print("Producer: finished")