Skip to content

Commit

Permalink
Fix "Event loop is closed" error on windows
Browse files Browse the repository at this point in the history
Switched from asyncio.run() to asyncio.get_event_loop.run_until_complete()
  • Loading branch information
mpearson authored and jerry-skydio committed Dec 22, 2023
1 parent 6c13d24 commit 9bfa7fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions revup/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

def _main() -> None:
try:
# Exit code of 1 is reserved for exception-based exits
sys.exit(asyncio.run(main()))
# Exit code of 1 is reserved for exception-based exits.
# Note: on Windows, asyncio.run() doesn't work properly due to this issue:
# https://stackoverflow.com/questions/63860576/asyncio-event-loop-is-closed-when-using-asyncio-run
# Since revup makes use of subprocess, we can't use WindowsSelectorEventLoopPolicy.
# Instead, we can manually create the event loop and prevent the RuntimeError on shutdown.
sys.exit(asyncio.get_event_loop().run_until_complete(main()))
except RevupUsageException as e:
logging.error(str(e))
sys.exit(2)
Expand Down

0 comments on commit 9bfa7fb

Please sign in to comment.