This commit is contained in:
rany
2022-03-09 20:23:31 +02:00
parent 7e0ae74546
commit 9cfb9cc1e5
3 changed files with 21 additions and 2 deletions

View File

@@ -25,4 +25,13 @@ async def main():
if __name__ == "__main__":
# Fix for "RuntimeError: Event loop is closed" on Windows
# and Python 3.8+
if (
os.name == "nt"
and sys.version_info >= (3, 8)
and hasattr(asyncio, "WindowsSelectorEventLoopPolicy")
):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())

View File

@@ -1,2 +1,2 @@
find src -name '*.py' | xargs black
find src -name '*.py' | xargs isort
find src examples -name '*.py' | xargs black
find src examples -name '*.py' | xargs isort

View File

@@ -5,6 +5,7 @@ Main package.
import argparse
import asyncio
import os
import sys
from edge_tts import Communicate, SubMaker, list_voices
@@ -153,6 +154,15 @@ def main():
"""
Main function.
"""
# Fix for "RuntimeError: Event loop is closed" on Windows
# and Python 3.8+
if (
os.name == "nt"
and sys.version_info >= (3, 8)
and hasattr(asyncio, "WindowsSelectorEventLoopPolicy")
):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(_main())