smbinterp/interp/cluster/__init__.py

29 lines
792 B
Python

from multiprocessing.managers import BaseManager
import Queue
tasks_q = Queue.Queue()
results_q = Queue.Queue()
minions_q = Queue.Queue()
master_q = Queue.Queue()
class QueueManager(BaseManager):
"""
One QueueManager to rule all network Queues
"""
pass
QueueManager.register('get_tasks_q' , callable=lambda:tasks_q )
QueueManager.register('get_results_q', callable=lambda:results_q )
QueueManager.register('get_minions_q', callable=lambda:minions_q )
QueueManager.register('get_master_q' , callable=lambda:master_q )
def get_qs(qm):
"""
pass in a QueueManager, and this function returns all relevant
queues attached to that QueueManager.
"""
return (qm.get_tasks_q(),
qm.get_results_q(),
qm.get_master_q(),
qm.get_minions_q())