Skip to content

Commit

Permalink
Explicitly set SelectorEventLoop on 3.8, Windows (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
iojw committed Jan 26, 2020
1 parent 637c7f1 commit 04fd646
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions socialscan/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import asyncio
import sys

from socialscan import cli


def main():
# 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(cli.main())


Expand Down

0 comments on commit 04fd646

Please sign in to comment.