Skip to content

Instantly share code, notes, and snippets.

@johngrantuk
Last active October 25, 2019 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johngrantuk/8db3bd2dd63454850e430503391880ab to your computer and use it in GitHub Desktop.
Save johngrantuk/8db3bd2dd63454850e430503391880ab to your computer and use it in GitHub Desktop.
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