Merge pull request #210 from zhoukuncheng/refactor-async

Simplify asyncio main loop setup
This commit is contained in:
Rany 2024-04-12 12:21:13 +03:00 committed by GitHub
commit bafe5d825a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 25 deletions

View File

@ -32,8 +32,4 @@ async def amain() -> None:
if __name__ == "__main__":
loop = asyncio.get_event_loop_policy().get_event_loop()
try:
loop.run_until_complete(amain())
finally:
loop.close()
asyncio.run(amain())

View File

@ -20,8 +20,4 @@ async def amain() -> None:
if __name__ == "__main__":
loop = asyncio.get_event_loop_policy().get_event_loop()
try:
loop.run_until_complete(amain())
finally:
loop.close()
asyncio.run(amain())

View File

@ -26,8 +26,4 @@ async def amain() -> None:
if __name__ == "__main__":
loop = asyncio.get_event_loop_policy().get_event_loop()
try:
loop.run_until_complete(amain())
finally:
loop.close()
asyncio.run(amain())

View File

@ -33,8 +33,4 @@ async def amain() -> None:
if __name__ == "__main__":
loop = asyncio.get_event_loop_policy().get_event_loop()
try:
loop.run_until_complete(amain())
finally:
loop.close()
asyncio.run(amain())

View File

@ -133,11 +133,7 @@ async def amain() -> None:
def main() -> None:
"""Run the main function using asyncio."""
loop = asyncio.get_event_loop_policy().get_event_loop()
try:
loop.run_until_complete(amain())
finally:
loop.close()
asyncio.run(amain())
if __name__ == "__main__":