- for market_config, user_id in fetch_markets(pg_config, args.user):
- try:
- market.Market\
- .from_config(market_config, debug=args.debug, user_id=user_id, report_path=report_path)\
- .process(args.action, before=args.before, after=args.after)
- except Exception as e:
- print("{}: {}".format(e.__class__.__name__, e))
+ if args.parallel:
+ import threading
+ market.Portfolio.start_worker()
+
+ for market_config, user_id in fetch_markets(pg_config, args.user):
+ threading.Thread(target=process, args=[market_config, user_id, report_path, args]).start()
+ else:
+ for market_config, user_id in fetch_markets(pg_config, args.user):
+ process(market_config, user_id, report_path, args)