import sys import zmq import json import time import uuid import Queue as queue import logging import traceback import threading import command stdout = sys.stdout log = command.setup_log('server') # Default verbosity, overriden via the command 'verbosity' log.setLevel(logging.INFO) context = zmq.Context() # The server will listen on port 5555 for incoming requests # from clients. It will execute them in a separate thread # and move onto listening for further commands. requests = context.socket(zmq.REP) requests.bind("tcp://*:5555") # While a command is being processed, the incoming socket # can continue taking on requests. Once a command is finished, # a message is sent to the client who initially made the request.
""" from __future__ import absolute_import import zmq import json import uuid import time import logging import threading # DES06 (see command.py) import command log = command.setup_log('client') log.setLevel(logging.INFO) # Each running client will have a unique ID # The server uses this ID to separate between commands # being executed and allows multiple clients to undo/redo # their own individual commands. UUID = str(uuid.uuid4()) context = zmq.Context() class Invoker(object): """Invoker ("waiter") Transmit command to server for execution and await results.