From 3bddf540b4666ae5db782d3ebe914eaa19d60663 Mon Sep 17 00:00:00 2001 From: Yuming Zhu Date: Wed, 25 Apr 2018 08:55:46 +0000 Subject: [PATCH] set default batch to None and use generator instead of list --- koji/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/koji/__init__.py b/koji/__init__.py index 4d1111f9..f97c03a8 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -2522,7 +2522,7 @@ class ClientSession(object): time.sleep(interval) #not reached - def multiCall(self, strict=False, batch=0): + def multiCall(self, strict=False, batch=None): """Execute a multicall (multiple function calls passed to the server and executed at the same time, with results being returned in a batch). Before calling this method, the self.multicall field must have @@ -2544,12 +2544,11 @@ class ClientSession(object): calls = self._calls self._calls = [] - if batch > 0: + if batch is not None and batch > 0: ret = [] - callgrp = [calls[i:i + batch] for i in - range(0, len(calls), batch)] - self.logger.debug("MultiCall with batch size %s, calls/groups(%s/%s)", - batch, len(calls), len(callgrp)) + callgrp = (calls[i:i + batch] for i in range(0, len(calls), batch)) + self.logger.debug("MultiCall with batch size %i, calls/groups(%i/%i)", + batch, len(calls), round(len(calls) / batch)) for c in callgrp: ret.extend(self._callMethod('multiCall', (c,), {})) else: