예제 #1
0
파일: base.py 프로젝트: pombredanne/unuk
class TestCase(TestCase):
    withpool = 1
    taskdir = "unuk.contrib.tasks.tests.tlib"

    def setUp(self):
        pool = getpool(self.withpool)
        self.controller = Controller(pool=pool, task_modules=["{0}.*".format(self.taskdir)], beat=0.5)
        self.controller.start()
        self.scheduler = self.controller.scheduler
        self.registry = registry

    def tearDown(self):
        self.controller.wait()
예제 #2
0
class JsonCalculator(JSONRPC):
    '''JSON RPC Server with a task controller'''
    def __init__(self, pool):
        logger = get_logger(name = 'taskqueue')
        super(JsonCalculator,self).__init__(logger = logger)
        self.controller = Controller(pool).start()
    
    def jsonrpc_calculate(self, request, **kwargs):
        '''Dispatch new task and returns task id'''
        request = self.controller.dispatch('taskqueue.tasks.calctask', **kwargs)
        request.bind('success',callback)
        return request.info.todict()
    
    def jsonrpc_shutdown(self, request, **kwargs):
        self.stop()
    
    def stop(self):
        self.logger.info('Stopping calculation pool')
        self.controller.stop()
예제 #3
0
 def __init__(self, pool):
     logger = get_logger(name = 'taskqueue')
     super(JsonCalculator,self).__init__(logger = logger)
     self.controller = Controller(pool).start()
예제 #4
0
파일: base.py 프로젝트: pombredanne/unuk
 def setUp(self):
     pool = getpool(self.withpool)
     self.controller = Controller(pool=pool, task_modules=["{0}.*".format(self.taskdir)], beat=0.5)
     self.controller.start()
     self.scheduler = self.controller.scheduler
     self.registry = registry