I have the following code:
async def main():
symbols = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT']
tasks = []
async with ClientSession() as session:
for x in symbols:
task = asyncio.create_task(nested('https://api.binance.com/api/v1/klines?&symbol={0}&interval={1}&limit=300'.format(symbol, tf), session, symbol))
tasks.append(task)
responses = await asyncio.gather(*tasks)
tasks.clear()
print(tasks)
await asyncio.sleep(25)
try:
assert isinstance(loop := asyncio.new_event_loop(), asyncio.ProactorEventLoop)
async def proactor_wrap(loop_: asyncio.ProactorEventLoop, fut: asyncio.coroutines):
await fut
loop_.stop()
loop.create_task(proactor_wrap(loop, main()))
loop.run_forever()
except (AssertionError, AttributeError):
asyncio.run(main())
How can i schedule the function main()
to run every x amount of time, for example every 10 minutes or every 2 hours? Can i use the schedule
module for this task?