Skip to content

Commit 8d6744b

Browse files
authored
Merge pull request #156 from noahbkim/pickling-fix
Move __name__ mangling to end of module
2 parents 6294e09 + 2e36f7b commit 8d6744b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

trio_asyncio/_loop.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ def set_event_loop(self, loop):
190190
super().set_event_loop(loop)
191191

192192

193-
# get_event_loop() without a running loop is deprecated in 3.12+. The logic for emitting the
194-
# DeprecationWarning walks the stack looking at module names in order to associate it with
195-
# the first caller outside asyncio. We need to pretend to be asyncio in order for that to work.
196-
if sys.version_info >= (3, 12):
197-
__name__ = "asyncio.fake.trio_asyncio._loop"
198-
199193
# Make sure we don't try to continue using the Trio loop after a fork()
200194
if hasattr(os, "register_at_fork"):
201195

@@ -687,3 +681,10 @@ def run_trio_task(proc, *args):
687681
will propagate to, and terminate, the trio-asyncio loop.
688682
"""
689683
_running_loop().run_trio_task(proc, *args)
684+
685+
686+
# get_event_loop() without a running loop is deprecated in 3.12+. The logic for emitting the
687+
# DeprecationWarning walks the stack looking at module names in order to associate it with
688+
# the first caller outside asyncio. We need to pretend to be asyncio in order for that to work.
689+
if sys.version_info >= (3, 12):
690+
__name__ = "asyncio.fake.trio_asyncio._loop"

0 commit comments

Comments
 (0)