def handle_reduce(self, reduce_function_names, mapped_docs):
reduce_functions = []<EOL>for reduce_function_name in reduce_function_names:<EOL><INDENT>try:<EOL><INDENT>reduce_function = get_function(reduce_function_name)<EOL>if getattr(reduce_function, '<STR_LIT>', None):<EOL><INDENT>reduce_function = reduce_function(self.log)<EOL><DEDENT>reduce_functions.append(reduce_function)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>self.log(repr(exc))<EOL>reduce_functions.append(lambda *args, **kwargs: None)<EOL><DEDENT><DEDENT>keys, values = list(zip(<EOL>(key, value) for ((key, doc_id), value) in mapped_docs))<EOL>results = []<EOL>for reduce_function in reduce_functions:<EOL><INDENT>try:<EOL><INDENT>results.append(reduce_function(keys, values, rereduce=False))<EOL><DEDENT>except Exception as exc:<EOL><INDENT>self.log(repr(exc))<EOL>results.append(None)<EOL><DEDENT><DEDENT>return [True, results]<EOL>
Reduce several mapped documents by several reduction functions.