Created
July 12, 2019 17:34
-
-
Save craigderington/39973c3c4e7c7534221e133dbe4397f3 to your computer and use it in GitHub Desktop.
Python while True loop updating Incoming Message UUID when Certain Conditions Exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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