bpo-32418: Add get_loop() method on Server, AbstractServer classes (#4997)
* Add abstract get_loop() method to Server, AbstractServer classes.
* Add test cases for get_loop() method in Server, AbstractServer classes
* Add documentation for get_loop() method
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 00831b3..ab00231 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -185,6 +185,9 @@
if self._active_count == 0:
self._wakeup()
+ def get_loop(self):
+ return self._loop
+
def _wakeup(self):
waiters = self._waiters
self._waiters = None
diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index 9496d5c..731a0c5 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -155,6 +155,10 @@
"""Coroutine to wait until service is closed."""
return NotImplemented
+ def get_loop(self):
+ """ Get the event loop the Server object is attached to."""
+ return NotImplemented
+
class AbstractEventLoop:
"""Abstract event loop."""