diff options
author | Yury Selivanov <yury@magic.io> | 2016-11-08 00:00:46 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-11-08 00:00:46 (GMT) |
commit | 6ea2b8fc8be8725e1553fbbb159ea07806e9f41a (patch) | |
tree | 87e0c4dd9e553efb3b2f93b74247e5d065c892b1 /Lib | |
parent | 49d6b8c0c3124e94728dd44aafc33becfb14415b (diff) | |
download | cpython-6ea2b8fc8be8725e1553fbbb159ea07806e9f41a.zip cpython-6ea2b8fc8be8725e1553fbbb159ea07806e9f41a.tar.gz cpython-6ea2b8fc8be8725e1553fbbb159ea07806e9f41a.tar.bz2 |
Issue #28613: Expose asyncio._get_running_loop() and _set_running_loop()
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/asyncio/events.py | 1 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_events.py | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py index 8575e2c..28a45fc 100644 --- a/Lib/asyncio/events.py +++ b/Lib/asyncio/events.py @@ -6,6 +6,7 @@ __all__ = ['AbstractEventLoopPolicy', 'get_event_loop_policy', 'set_event_loop_policy', 'get_event_loop', 'set_event_loop', 'new_event_loop', 'get_child_watcher', 'set_child_watcher', + '_set_running_loop', '_get_running_loop', ] import functools diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 4c18300..d6489d5 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -2732,9 +2732,11 @@ class PolicyTests(unittest.TestCase): try: asyncio.set_event_loop_policy(Policy()) loop = asyncio.new_event_loop() + self.assertIs(asyncio._get_running_loop(), None) async def func(): self.assertIs(asyncio.get_event_loop(), loop) + self.assertIs(asyncio._get_running_loop(), loop) loop.run_until_complete(func()) finally: @@ -2742,6 +2744,8 @@ class PolicyTests(unittest.TestCase): if loop is not None: loop.close() + self.assertIs(asyncio._get_running_loop(), None) + if __name__ == '__main__': unittest.main() |