I am using python for Binance future transactions.
The problem is that the program keeps stopping running with an error message “Event loop is closed.”
I have tried different solutions which google and chat-gpt suggested, but the program still stops running.
Below are my codes.
async def main():
try:
while True:
await function_1()
await function_2()
await function_3()
await asyncio.sleep(1)
except RuntimeError as e:
if str(e) == "Event loop is closed":
first try
asyncio.set_event_loop(asyncio.new_event_loop())
asyncio.get_event_loop()
asyncio.run(main())
second try
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
if __name__ == "__main__":
asyncio.run(main())