Skip to content

Instantly share code, notes, and snippets.

@Mufanc
Last active September 6, 2021 10:26
Show Gist options
  • Save Mufanc/613c30821991646ad4742894704ba450 to your computer and use it in GitHub Desktop.
Save Mufanc/613c30821991646ad4742894704ba450 to your computer and use it in GitHub Desktop.
[Python asyncio 协程关闭问题] 报 RuntimeError: Event loop is closed 的解决方案 #Python
import asyncio
async def main():
# do something
pass
if __name__ == '__main__':
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(main())
finally:
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment