-
Notifications
You must be signed in to change notification settings - Fork 0
/
redis_pub.py
32 lines (23 loc) · 1.31 KB
/
redis_pub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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())
RedisCheck()