Skip to content

Commit

Permalink
fix: workaround for missing event loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
crebsy committed Jun 1, 2023
1 parent b5bdcc6 commit 0603f2e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions a_sync/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def _await(awaitable: Awaitable[T]) -> T:
except RuntimeError as e:
if str(e) == "This event loop is already running":
raise RuntimeError(str(e), running_event_loop_msg)
elif str(e).startswith("There is no current event loop in thread"):
loop = asyncio.new_event_loop()
return loop.run_until_complete(awaitable)
raise

def _asyncify(func: SyncFn[P, T], executor: Executor) -> CoroFn[P, T]:
Expand Down

0 comments on commit 0603f2e

Please sign in to comment.