diff --git a/CHANGELOG.md b/CHANGELOG.md index baf4a5d1..abbb327b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.0.5 - - Allow nested `with` contexts [#690](https://github.com/amoffat/sh/issues/690) +- Call correct asyncio function for getting event loop [#683](https://github.com/amoffat/sh/issues/683) ## 2.0.4 - 5/13/22 diff --git a/sh.py b/sh.py index 633a1bc6..955c94c5 100644 --- a/sh.py +++ b/sh.py @@ -649,7 +649,7 @@ def __init__(self, cmd, call_args, stdin, stdout, stderr): # this event is used when we want to `await` a RunningCommand. see how it gets # used in self.__await__ try: - asyncio.get_event_loop() + asyncio.get_running_loop() except RuntimeError: self.aio_output_complete = None else: @@ -2383,7 +2383,7 @@ def fn(exit_code): # if the `sh` command was launched from within a thread (so we're not in # the main thread), then we won't have an event loop. try: - loop = asyncio.get_event_loop() + loop = asyncio.get_running_loop() except RuntimeError: def output_complete():