Created
October 25, 2020 13:22
-
-
Save ozkansen/3b36b46e150b1a1b91f34bb5326ec2eb 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
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