Skip to content

Commit aa6549a

Browse files
committed
Fix asyncio.get_running_loop() monkey-patching (python-trio#83)
1 parent 1ed96e5 commit aa6549a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

newsfragments/99.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`asyncio.get_running_loop()` will now return the trio-asyncio event loop
2+
(if running), instead of failing with :exc:`RuntimeError`.

trio_asyncio/_loop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ def _new_run_get_or_throw():
251251

252252
_aio_event._get_running_loop = _new_run_get
253253
_aio_event.get_running_loop = _new_run_get_or_throw
254+
asyncio._get_running_loop = _new_run_get
255+
asyncio.get_running_loop = _new_run_get_or_throw
254256

255257
#####
256258

0 commit comments

Comments
 (0)