From e7d7c0e5645da35adcbfec9e51deb68f012c422f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 7 Apr 2018 17:39:29 +0200 Subject: Acceptance test preparation Save some headers for http requests Wait for all threads after the end of main Simplify library imports for mocking --- main.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 6383ed1..2cfb01d 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -from datetime import datetime import configargparse import psycopg2 import os @@ -170,13 +169,21 @@ def main(argv): import threading market.Portfolio.start_worker() + threads = [] def process_(*args): - threading.Thread(target=process, args=args).start() + thread = threading.Thread(target=process, args=args) + thread.start() + threads.append(thread) else: process_ = process for market_id, market_config, user_id in fetch_markets(pg_config, args.user): process_(market_config, market_id, user_id, args, pg_config) + if args.parallel: + for thread in threads: + thread.join() + market.Portfolio.stop_worker() + if __name__ == '__main__': # pragma: no cover main(sys.argv[1:]) -- cgit v1.2.3