-
Notifications
You must be signed in to change notification settings - Fork 0
/
async_main.py
executable file
·45 lines (37 loc) · 1.22 KB
/
async_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import time
import asyncio
import logging
import logging.config
import yaml
import json
from async_Analyst import Analyst
if __name__ == '__main__':
with open('credentials.json') as f:
j = json.load(f)
data = {
'pw' : j['pw'],
'acc' : j['acc'],
'url' : 'wss://bitshares.openledger.info/ws',
'major_coin' : 'BRIDGE.BTC',
'whitelist' : ['BRIDGE.GIN', 'BRIDGE.SINS'],
'blacklist' : ['BRIDGE.BTS'],
}
#logging
with open('./logging.yml', 'r') as stream:
config = yaml.load(stream)
#logging.config.dictConfig(config)
logging.basicConfig(format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p',
filename='logs.log',
level=logging.WARNING) # info else
#async
loop = asyncio.get_event_loop()
logger = logging.getLogger()
logger.propagate = False
ana = Analyst.from_kwargs(loop, logger, **data)
managers, workers = ana.populate()
producer_coro = [w.run() for w in workers]
consumer_coro = [m.run() for m in managers]
ana.loop.run_until_complete(asyncio.gather(*producer_coro, *consumer_coro))
ana.loop.close()