我正在编写一个必须自动重新启动的函数,以防捕获异常,但是我不知道该怎么做。 我有这段代码,但是没有用。:
import asyncio
async def main():
while True:
try:
#REALLY huge amount of code
except Exception as e:
print(f"Exception: {e}")
# Here I want this script to run main() again
return
asyncio.run(main())