Last active
October 25, 2019 13:58
-
-
Save johngrantuk/8db3bd2dd63454850e430503391880ab to your computer and use it in GitHub Desktop.
This file contains 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 redis | |
import time | |
import traceback | |
def RedisCheck(): | |
try: | |
r = redis.StrictRedis(host='localhost', port=6379) # Connect to local Redis instance | |
p = r.pubsub() # See https://github.com/andymccurdy/redis-py/#publish--subscribe | |
p.subscribe('startScripts') # Subscribe to startScripts channel | |
PAUSE = True | |
while PAUSE: # Will stay in loop until START message received | |
print("Waiting For redisStarter...") | |
message = p.get_message() # Checks for message | |
if message: | |
command = message['data'] # Get data from message | |
if command == b'START': # Checks for START message | |
PAUSE = False # Breaks loop | |
time.sleep(1) | |
print("Permission to start...") | |
except Exception as e: | |
print("!!!!!!!!!! EXCEPTION !!!!!!!!!") | |
print(str(e)) | |
print(traceback.format_exc()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment