diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1,4 +1,3 @@ | |||
1 | from datetime import datetime | ||
2 | import configargparse | 1 | import configargparse |
3 | import psycopg2 | 2 | import psycopg2 |
4 | import os | 3 | import os |
@@ -170,13 +169,21 @@ def main(argv): | |||
170 | import threading | 169 | import threading |
171 | market.Portfolio.start_worker() | 170 | market.Portfolio.start_worker() |
172 | 171 | ||
172 | threads = [] | ||
173 | def process_(*args): | 173 | def process_(*args): |
174 | threading.Thread(target=process, args=args).start() | 174 | thread = threading.Thread(target=process, args=args) |
175 | thread.start() | ||
176 | threads.append(thread) | ||
175 | else: | 177 | else: |
176 | process_ = process | 178 | process_ = process |
177 | 179 | ||
178 | for market_id, market_config, user_id in fetch_markets(pg_config, args.user): | 180 | for market_id, market_config, user_id in fetch_markets(pg_config, args.user): |
179 | process_(market_config, market_id, user_id, args, pg_config) | 181 | process_(market_config, market_id, user_id, args, pg_config) |
180 | 182 | ||
183 | if args.parallel: | ||
184 | for thread in threads: | ||
185 | thread.join() | ||
186 | market.Portfolio.stop_worker() | ||
187 | |||
181 | if __name__ == '__main__': # pragma: no cover | 188 | if __name__ == '__main__': # pragma: no cover |
182 | main(sys.argv[1:]) | 189 | main(sys.argv[1:]) |