diff --git a/CHANGES.rst b/CHANGES.rst index 60c7b1d0075..1cca35e9cac 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -116,6 +116,8 @@ CHANGES - Add `multipart` coroutine method for web Request object #1067 +- Publish ClientSession.loop property #1149 + - - diff --git a/aiohttp/client.py b/aiohttp/client.py index ed8fb065815..2bbad0681b7 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -476,6 +476,11 @@ def version(self): """The session HTTP protocol version.""" return self._version + @property + def loop(self): + """Session's loop.""" + return self._loop + def detach(self): """Detach connector from session without closing the former. diff --git a/docs/client_reference.rst b/docs/client_reference.rst index c6d9fb5a4a1..a4ed848dbe5 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -120,6 +120,11 @@ The client session supports the context manager protocol for self closing. A read-only property. Overriding `session.cookies = new_val` is forbidden, but you may modify the object in-place if needed. + .. attribute:: loop + + A loop instance used for session creation. + + A read-only property. .. comethod:: request(method, url, *, params=None, data=None,\ headers=None, skip_auto_headers=None, \ diff --git a/tests/test_client_session.py b/tests/test_client_session.py index e03b06698c9..86c4c1f5dc0 100644 --- a/tests/test_client_session.py +++ b/tests/test_client_session.py @@ -418,3 +418,8 @@ def handler(request): def test_session_default_version(loop): session = aiohttp.ClientSession(loop=loop) assert session.version == aiohttp.HttpVersion11 + + +def test_session_loop(loop): + session = aiohttp.ClientSession(loop=loop) + assert session.loop is loop