Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

aio: add await for session closing#275

Closed
RazAnyVision wants to merge 1 commit intopython-consul:masterfrom
RazAnyVision:patch-1
Closed

aio: add await for session closing#275
RazAnyVision wants to merge 1 commit intopython-consul:masterfrom
RazAnyVision:patch-1

Conversation

@RazAnyVision
Copy link

aio.Consul.close() uses aiohttp.ClientSession.close() which returns a coroutine that was never awaited. When this happens, RuntimeWarnings are raised on termination:

RuntimeWarning: coroutine 'ClientSession.close' was never awaited
  self._session.close()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fee7d894340>
Unclosed connector
connections: [<a long list of connections>]
connector: <aiohttp.connector.TCPConnector object at 0x7fee7d894310>

I've added await for the close coroutine and by that avoids these warnings.

aio.Consul.close() uses aiohttp.ClientSession.close() which returns a coroutine that was never awaited. When this happens, RuntimeWarnings are raised on termination:

    RuntimeWarning: coroutine 'ClientSession.close' was never awaited
      self._session.close()
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    Unclosed client session
    client_session: <aiohttp.client.ClientSession object at 0x7fee7d894340>
    Unclosed connector
    connections: [<a long list of connections>]
    connector: <aiohttp.connector.TCPConnector object at 0x7fee7d894310>
    
I've added await for the close coroutine and by that avoids these warnings.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant