mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Use event loop workaround only on windows
This avoids an unnecessary one-second sleep on other platforms. However, a better "fix" for this sleep would be a less ugly workaround on windows.
This commit is contained in:
parent
b78eb64f3d
commit
84f775013f
@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import configparser
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@ -118,10 +119,18 @@ def main() -> None:
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
if os.name == "nt":
|
||||
# A "workaround" for the windows event loop somehow crashing after
|
||||
# asyncio.run() completes. See:
|
||||
# https://bugs.python.org/issue39232
|
||||
# https://github.com/encode/httpx/issues/914#issuecomment-780023632
|
||||
# TODO Fix this properly
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(pferd.run(args.debug_transforms))
|
||||
loop.run_until_complete(asyncio.sleep(1))
|
||||
loop.close()
|
||||
else:
|
||||
asyncio.run(pferd.run(args.debug_transforms))
|
||||
except ConfigOptionError as e:
|
||||
log.unlock()
|
||||
log.error(str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user