Exemple #1
0
    def dispatch(self, task_name, *args, **kwargs):
        '''Dispatch a task to the processing pool.

Returns an instance of :class:`TaskRequest`.'''
        task_id = gen_unique_id()
        self.logger.debug('Dispatching task %s to the processing pool' % task_id)
        request = self.Request(self,
                               task_name,
                               task_id,
                               self.task_modules,
                               args,
                               kwargs,
                               logger = self.logger)
        code = request.info.code
        old_request = self._cachecode.get(code,None)
        if old_request:
            if old_request.info.time_end:
                self._cachecode.pop(code)
            return old_request
        finished = self.request_finished
        request.bind('success',finished).bind('failed',finished)
        self._add(request)
        request.execute_using_pool(self.pool)
        return request
Exemple #2
0
 def makeid(self):
     '''
     Can be re-implemented by your own Proxy
     '''
     return gen_unique_id()