Skip to content

Instantly share code, notes, and snippets.

@ozkansen
Created October 25, 2020 13:22
Show Gist options
  • Save ozkansen/3b36b46e150b1a1b91f34bb5326ec2eb to your computer and use it in GitHub Desktop.
Save ozkansen/3b36b46e150b1a1b91f34bb5326ec2eb to your computer and use it in GitHub Desktop.
def connect_channel(self, channel, delay=1/4):
listen = self.r.pubsub()
listen.subscribe(channel)
self.r.publish(channel, "a::1")
def start_process():
while True:
message = listen.get_message()
time.sleep(delay)
if message and not message["data"] == 1:
message = message["data"].decode("utf-8")
print(f"Received command: {message}")
action, platform = message.split("::")
print(f"Action: {action} on platform: {platform}")
p1 = Process(target=start_process, name="zzzzzzzzz")
p1.start()
p1.join(timeout=5)
p1.terminate()
return "xxxxxxxxxx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment