33 lines
681 B
Python
33 lines
681 B
Python
import asyncio
|
|
import logging
|
|
import pybotters
|
|
import signal
|
|
|
|
import bitbank
|
|
|
|
|
|
async def main():
|
|
alive = True
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
def teardown():
|
|
nonlocal alive
|
|
alive = False
|
|
for t in asyncio.all_tasks():
|
|
t.cancel()
|
|
|
|
loop = asyncio.get_event_loop()
|
|
loop.add_signal_handler(signal.SIGTERM, teardown)
|
|
loop.add_signal_handler(signal.SIGINT, teardown)
|
|
|
|
async with pybotters.Client(apis="secret.json") as cli:
|
|
await asyncio.gather(bitbank.init(cli))
|
|
while alive: await asyncio.sleep(0.5)
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
loop = asyncio.new_event_loop()
|
|
loop.run_until_complete(main())
|
|
finally:
|
|
loop.close()
|