From 9a40cecc37cdae394e69a5ce053ace8b5fad951b Mon Sep 17 00:00:00 2001 From: Ryan Bonham Date: Thu, 8 Nov 2018 11:05:20 -0600 Subject: [PATCH] Thread Pool getSecretAction when using wildcards. --- .gitignore | 3 +++ credstash.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index fc6568c..35e7c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ target/ .DS_Store *swp *scratch*.py + +#Ignore MyPy Cache +.mypy_cache/ \ No newline at end of file diff --git a/credstash.py b/credstash.py index e051874..60597b6 100755 --- a/credstash.py +++ b/credstash.py @@ -427,14 +427,14 @@ def getSecretAction(args, region, **session_params): in listSecrets(region=region, table=args.table, **session_params)]) - secrets = dict((name, - getSecret(name, - args.version, - region=region, - table=args.table, - context=args.context, - **session_params)) - for name in names) + + pool = ThreadPool(min(len(names), THREAD_POOL_MAX_SIZE)) + results = pool.map( + lambda credential: getSecret(credential, args.version, region, args.table, args.context, **session_params), + names) + pool.close() + pool.join() + secrets =dict(zip(names, results)) if args.format == "json": output_func = json.dumps output_args = {"sort_keys": True,