Skip to content

Commit

Permalink
AioSession defaults to asyncio current loop (#758)
Browse files Browse the repository at this point in the history
- apply the default in the class initializer rather
  than the utility function that wraps it.

Co-authored-by: Alexander Mohr <thehesiod@users.noreply.github.com>
  • Loading branch information
dazza-codes and thehesiod committed Feb 15, 2020
1 parent 345b8e1 commit 680814b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions aiobotocore/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class AioSession(botocore.session.Session):

def __init__(self, *args, loop=None, **kwargs):
self._loop = loop
self._loop = loop or asyncio.get_event_loop()

super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -87,5 +87,4 @@ def get_session(*, env_vars=None, loop=None):
"""
Return a new session object.
"""
loop = loop or asyncio.get_event_loop()
return AioSession(env_vars, loop=loop)
6 changes: 6 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,9 @@ async def test_connector_timeout2(event_loop):
with pytest.raises(ReadTimeoutError):
resp = await s3_client.get_object(Bucket='foo', Key='bar')
await resp["Body"].read()


@pytest.mark.moto
def test_default_event_loop():
session = AioSession()
assert session._loop == asyncio.get_event_loop()

0 comments on commit 680814b

Please sign in to comment.