]> granicus.if.org Git - python/commitdiff
Issue #28613: Expose asyncio._get_running_loop() and _set_running_loop()
authorYury Selivanov <yury@magic.io>
Tue, 8 Nov 2016 00:00:46 +0000 (19:00 -0500)
committerYury Selivanov <yury@magic.io>
Tue, 8 Nov 2016 00:00:46 +0000 (19:00 -0500)
Lib/asyncio/events.py
Lib/test/test_asyncio/test_events.py

index 8575e2c1c4029c15f1f1e7043fabcbd245fce8ee..28a45fc3cc5aee50496d6c56db1c8772ba3f209b 100644 (file)
@@ -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
index 4c18300bab25c886233e8558197eb4b38aeeb3b6..d6489d5f8d13f1e29299e3ea395a572d65c33506 100644 (file)
@@ -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()