in aws_resource_scan.py [0:0]
def execute_query(to_run, verbose, parallel, results_by_type):
"""Execute created queries.
Args:
to_run: queries to execute.
verbose: enable verbose mode.
parallel: number of threads to start.
results_by_type: query results.
Returns:
results by type
"""
# the `with` block is a workaround for a bug:
# https://bugs.python.org/issue35629
with contextlib.closing(ThreadPool(parallel)) as pool:
for result in pool.imap_unordered(functools.partial(acquire_listing,
verbose), to_run):
results_by_type[result.result_type].append(result)
if verbose > 1:
print('ExecutedQueryResult: {}'.format(result.to_tuple))
else:
sys.stdout.flush()
return results_by_type