Skip to content

Commit

Permalink
Merge pull request #23 from chronoB/aiohttpWorkaround
Browse files Browse the repository at this point in the history
added workaround for error of aiohttp in python38
  • Loading branch information
vigonotion authored Apr 17, 2020
2 parents 9d30732 + 52b2ebd commit a3a386c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import os
import sys
from datetime import datetime, timedelta

import aiohttp
Expand Down Expand Up @@ -214,4 +215,15 @@ async def main():
print(tl)


# To avoid 'Event loop is closed' RuntimeError due to compatibility issue with aiohttp
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
try:
from asyncio import WindowsSelectorEventLoopPolicy
except ImportError:
pass
else:
if not isinstance(
asyncio.get_event_loop_policy(), WindowsSelectorEventLoopPolicy
):
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
asyncio.run(main())

0 comments on commit a3a386c

Please sign in to comment.