Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python while True loop updating Incoming Message UUID when Certain Conditions Exist
import os
import time
import uuid
import random
from datetime import datetime, timedelta
def get_message():
return uuid.uuid4()
def main():
incoming_msg = "DATA BUFFERS FLUSHED"
stored_msg = "INITIALIZING APPLICATION"
while True:
x = random.randint(0, 10)
y = random.randint(0, 10)
if x == y:
incoming_msg = get_message()
try:
if stored_msg != incoming_msg:
print("Stored Message: {}, Incoming Message: {}, x equals {}, y equals {}".format(stored_msg, incoming_msg, str(x), str(y)))
stored_msg = incoming_msg
time.sleep(2)
else:
print("Incoming message equals stored message: {}, x equals {}, y equals {}.".format(incoming_msg, str(x), str(y)))
time.sleep(2)
except TypeError as te:
print("Type error: " + str(te))
break
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.