Skip to content

Commit 99c81bf

Browse files
committed
Revert "Refactoring on worker threads."
This reverts commit 7f5c257.
1 parent 60a6408 commit 99c81bf

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

app/app.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,43 @@ def main():
3838
logger.info("No configured markets, using all available on exchange.")
3939
market_data = exchange_interface.get_exchange_markets()
4040

41+
# notifier = Notifier(config.notifiers, market_data)
42+
4143
thread_list = []
4244

4345
for exchange in market_data:
44-
for key in market_data[exchange].keys():
45-
46+
num = 1
47+
for chunk in split_market_data(market_data[exchange]):
4648
market_data_chunk = dict()
47-
market_data_chunk[exchange] = {key : market_data[exchange][key]}
48-
49-
workerName = "Worker-{}-{}".format(exchange, key)
49+
market_data_chunk[exchange] = { key: market_data[exchange][key] for key in chunk }
5050

5151
notifier = Notifier(config.notifiers, config.indicators, market_data_chunk)
52-
behaviour = Behaviour(config, exchange_interface, notifier)
53-
52+
behaviour = Behaviour(config, exchange_interface, notifier)
53+
54+
workerName = "Worker-{}".format(num)
5455
worker = AnalysisWorker(workerName, behaviour, notifier, market_data_chunk, settings, logger)
5556
thread_list.append(worker)
5657
worker.daemon = True
5758
worker.start()
58-
time.sleep(2)
59-
59+
60+
time.sleep(60)
61+
num += 1
62+
6063
logger.info('All workers are running!')
6164

6265
for worker in thread_list:
6366
worker.join()
6467

65-
"""
6668
def split_market_data(market_data):
6769
if len(market_data.keys()) > 20:
6870
return list(chunks(list(market_data.keys()), 20))
6971
else:
7072
return [list(market_data.keys())]
7173

7274
def chunks(l, n):
75+
"""Yield successive n-sized chunks from l."""
7376
for i in range(0, len(l), n):
7477
yield l[i:i + n]
75-
"""
7678

7779
class AnalysisWorker(Thread):
7880

0 commit comments

Comments
 (0)