8 from Queue import Queue
10 # Located in the parent directory; execute from that location or put it in PYTHONPATH
15 class LBWorker(threading.Thread):
17 Load Balancing Worker: chooses a CIS where the request should be forwarded
18 or broadcasts the requests to all CIS machines if required.
21 def __init__(self, id):
23 Initialize Load Balancing Worker.
26 threading.Thread.__init__(self, name = 'LBWorker%02d' % id)
31 job = Server.queue.get()
33 print '%s is working at %s...' % (self.name, repr(job))
36 Server.queue.task_done()
41 def POST(self, request):
43 Server.queue.put( ('POST', request, web.data()) )
47 if __name__ == '__main__':
49 Server.queue = Queue()
53 for i in range(0, config.JOB_THREADS_COUNT):
54 lb_worker = LBWorker(i)
55 lb_worker.daemon = True
57 lb_workers.append(lb_worker)
60 urls = ('/(.*)', 'Server')
61 app = web.application(urls, globals())