aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/main.py b/main.py
index 6383ed1..2cfb01d 100644
--- a/main.py
+++ b/main.py
@@ -1,4 +1,3 @@
1from datetime import datetime
2import configargparse 1import configargparse
3import psycopg2 2import psycopg2
4import os 3import 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
181if __name__ == '__main__': # pragma: no cover 188if __name__ == '__main__': # pragma: no cover
182 main(sys.argv[1:]) 189 main(sys.argv[1:])