Skip to content

Instantly share code, notes, and snippets.

@craigderington
Created July 12, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigderington/39973c3c4e7c7534221e133dbe4397f3 to your computer and use it in GitHub Desktop.
Save craigderington/39973c3c4e7c7534221e133dbe4397f3 to your computer and use it in GitHub Desktop.
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