From 5f2a721426c5e55e755c65b946910ba752acf327 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 20 May 2018 19:26:26 +0200 Subject: rudimentary pausejabber --- rpc/rpc.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'rpc/rpc.py') diff --git a/rpc/rpc.py b/rpc/rpc.py index 957a049..3239c44 100644 --- a/rpc/rpc.py +++ b/rpc/rpc.py @@ -13,7 +13,7 @@ class CortexRPC(object): def __init__(self, fn): super().__init__() self._listener = fn - self.fetching = False + self.working = False self.connect() def connect(self): @@ -40,14 +40,17 @@ class CortexRPC(object): # return self.get_last_frame() def get_last_frame(self): - if self.fetching: + if self.working: + self.working = False return "working" path = os.getenv('TEST_FRAMES_PATH') onlyfiles = sorted([f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]) - self.fetching = True + self.working = True for f in onlyfiles: gevent.sleep(1/10) + if not self.working: + return output = BytesIO() im = Image.open(os.path.join(path, f)) # im = im.convert('RGB') @@ -56,7 +59,7 @@ class CortexRPC(object): output.close() self.send_frame(f.replace('png', 'jpg'), frame) - self.fetching = False + self.working = False return "ok" def send_param(self, key, value): -- cgit v1.2.3-70-g09d2