X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=main.py;fp=main.py;h=2cfb01dfce5d39cf8d63e64a117ae86b80372a2b;hb=e7d7c0e5645da35adcbfec9e51deb68f012c422f;hp=6383ed17775f185ad3973358a9bbcbc3a83b3a0c;hpb=c682bdf4a02a45312ef1aadf8aa26136cf308414;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git 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:])