feat (ui): synchronisation tasks
This commit is contained in:
16
client.py
16
client.py
@ -16,14 +16,10 @@ from .libs import dump_anything, umsgpack, zmq
|
||||
# import zmq
|
||||
lock = threading.Lock()
|
||||
|
||||
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
|
||||
CONNECT_TIMEOUT = 2
|
||||
WAITING_TIME = 0.001
|
||||
SERVER_MAX = 1
|
||||
@ -34,6 +30,7 @@ class State(Enum):
|
||||
INITIAL = 1
|
||||
SYNCING = 2
|
||||
ACTIVE = 3
|
||||
WORKING = 4
|
||||
|
||||
|
||||
def zpipe(ctx):
|
||||
@ -58,6 +55,8 @@ class RCFClient(object):
|
||||
pipe = None
|
||||
net_agent = None
|
||||
store = None
|
||||
active_tasks = None
|
||||
|
||||
def __init__(self):
|
||||
self.ctx = zmq.Context()
|
||||
self.pipe, peer = zpipe(self.ctx)
|
||||
@ -89,6 +88,10 @@ class RCFClient(object):
|
||||
self.watchdog_agent.daemon = True
|
||||
self.watchdog_agent.start()
|
||||
|
||||
# Status
|
||||
self.active_tasks = 0
|
||||
|
||||
|
||||
def connect(self, id, address, port):
|
||||
self.pipe.send_multipart([b"CONNECT", (id.encode() if isinstance(
|
||||
id, str) else id), (address.encode() if isinstance(
|
||||
@ -136,10 +139,11 @@ class RCFClient(object):
|
||||
|
||||
# self.pipe.send_multipart(
|
||||
# [b"ADD", umsgpack.packb(key), (umsgpack.packb(value) if value else umsgpack.packb('None'))])
|
||||
|
||||
|
||||
|
||||
def is_busy(self):
|
||||
if self.serial_feed.qsize() == 0 and self.serial_product.qsize() == 0:
|
||||
self.active_tasks = self.serial_feed.qsize() + self.serial_product.qsize()
|
||||
if self.active_tasks == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
Reference in New Issue
Block a user