Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Potential fix for issue #65
Browse files Browse the repository at this point in the history
  • Loading branch information
erdewit committed Apr 2, 2022
1 parent 616d9a5 commit 3cfd2c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nest_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def _patch_asyncio():
use module level _current_tasks, all_tasks and patch run method.
"""
def run(main, *, debug=False):
loop = events._get_running_loop()
if not loop:
loop = events.new_event_loop()
events.set_event_loop(loop)
try:
loop = asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
_patch_loop(loop)
loop.set_debug(debug)
task = asyncio.ensure_future(main)
Expand Down

0 comments on commit 3cfd2c8

Please sign in to comment.