diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-07 17:39:29 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-07 19:43:48 +0200 |
commit | e7d7c0e5645da35adcbfec9e51deb68f012c422f (patch) | |
tree | 990a884e058cff0467f7486efb422fb6b659f709 /main.py | |
parent | c682bdf4a02a45312ef1aadf8aa26136cf308414 (diff) | |
download | Trader-e7d7c0e5645da35adcbfec9e51deb68f012c422f.tar.gz Trader-e7d7c0e5645da35adcbfec9e51deb68f012c422f.tar.zst Trader-e7d7c0e5645da35adcbfec9e51deb68f012c422f.zip |
Acceptance test preparation
Save some headers for http requests
Wait for all threads after the end of main
Simplify library imports for mocking
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:]) |