diff --git a/swh/indexer/cli.py b/swh/indexer/cli.py --- a/swh/indexer/cli.py +++ b/swh/indexer/cli.py @@ -222,18 +222,18 @@ 'origin_metadata': origin_metadata_task_type, } ) - nb_messages = 0 last_log_time = 0 try: - while not stop_after_objects or nb_messages < stop_after_objects: - nb_messages += client.process(worker_fn) - if time.monotonic() - last_log_time >= 60: - print('Processed %d messages.' % nb_messages) - last_log_time = time.monotonic() + nb_messages = client.process(worker_fn) + if time.monotonic() - last_log_time >= 60: + print('Processed %d messages.' % nb_messages) + last_log_time = time.monotonic() except KeyboardInterrupt: ctx.exit(0) else: print('Done.') + finally: + client.close() @cli.command('rpc-serve')