From 801d0d7c75df045394ca70f94537fa52e3d050c2 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 19 May 2015 22:13:36 +0200 Subject: [PATCH] metasync: send actions by batch of size 100 --- lib/metasync | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/metasync b/lib/metasync index ee48497..74c1a99 100755 --- a/lib/metasync +++ b/lib/metasync @@ -361,18 +361,16 @@ def apply_action(action): actions.sort(key=lambda x: (x[0] == DELETE, len(x[1]))) if args.verbose: print 'Actions:' -for action in actions: +for batch in batch_generator(actions, 100): + for action in batch: + if args.verbose: + print_action(action) + if not args.fake: + apply_action(action) + else: + print 'Fake, doing nothing' if args.verbose: - print_action(action) - if not args.fake: - apply_action(action) - else: - print 'Fake, doing nothing' - -if args.verbose: - print 'Waiting for completion..', -i = len(actions) -while i: - lconn.result() - i -= 1 -print ' done' + print 'Waiting for completion..', + for action in batch: + lconn.result() + print ' done'