Example #1
 def start_mr(self, socket, full, collection, filter=None,
              map=None, reduce=None, finalize=None,
              map_name=None, reduce_name=None, finalize_name=None,
              inputs=None, output_type=None):
     if inputs is None:
         inputs = self._inputs
     req = {
         '$command': 'mapreduce',
     if full:
         req['output_type'] = 'replace'
         req['output_type'] = 'reduce'
     if output_type is not None:
         req['output_type'] = output_type
     query = dict(self._query)
     if filter: query.update(filter)
     log.debug('query=%s' % query)
     req['query'] = bson.Binary(bson.BSON.encode(query))
     if map is not None:
         if map_name is None: map_name = map.func_name
         req.update(map_text=func_text(map), map_name=map_name)
     if reduce is not None:
         if reduce_name is None: reduce_name = reduce.func_name
         req.update(reduce_text=func_text(reduce), reduce_name=reduce_name)
     if finalize is not None:
         if finalize_name is None: finalize_name = finalize.func_name
         req.update(finalize_text=func_text(finalize), finalize_name=finalize_name)
     r = req_bson(socket, req)
     return r
Example #2
 def start_basic_job(self, socket, func, *args, **kwargs):
     '''Start a (single-threaded) job to be run on a worker.'''
     req = {
         '$command': 'basic',
         'kwargs':kwargs }
     req['func_name'] = func.func_name
     req['func_text'] = func_text(func)
     r = req_bson(socket, req)
     return r