diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-08 00:53:34 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-08 00:53:34 +0200 |
commit | c8df27385e02b22d36b240fe29532e97dbba1f43 (patch) | |
tree | 44d7f9089468f35277bb8d0257da0f3a3bb88448 /main.py | |
parent | e6015816224f8f405e9b1c9557f22e73b21246e8 (diff) | |
parent | 1d72880c097ea8259ce9cc63cfe55e6cc7516bd2 (diff) | |
download | Trader-c8df27385e02b22d36b240fe29532e97dbba1f43.tar.gz Trader-c8df27385e02b22d36b240fe29532e97dbba1f43.tar.zst Trader-c8df27385e02b22d36b240fe29532e97dbba1f43.zip |
Merge branch 'test_cleanup' into dev
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:]) |