question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclosed connector

See original GitHub issue

Hi,

I am getting an error message when using the client.

Error message

Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fb608150c88>, 170770.66)]']
connector: <aiohttp.connector.TCPConnector object at 0x7fb608128588>

My code:

elastic_client = AsyncElasticsearch([f'{ES_USER}:{ES_PASSWORD}@{ES_HOST}'], loop=eloop)
await elastic_client.index(index=es_index(doc_type), doc_type=doc_type, body=activity)
elastic_client.transport.close()

This is called in an aiohttp.web.Application middleware. The loop is created when the app is created using asyncio.get_event_loop().

The request still succeeds, but the message is noisy.

I have tried with and without the line elastic_client.transport.close() to no avail. And sometimes (sporadically) with it there I get the error message:

/usr/local/lib/python3.6/site-packages/elasticsearch/connection_pool.py:255: RuntimeWarning: coroutine 'ClientSession.close' was never awaited

However await the same line throws a different error.

Versions:

python ==3.6.4 elasticsearch-async ==6.0.0 aiohttp ==3.1.3

Am I doing something wrong, or is this a bug?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
levchikcommented, May 17, 2018

I’m experiencing the same issues. After server (we use sanic) stops, massive traceback occurs about error in closing session. I saw #39 PR and I think this is great and should be merged as soon as possible.

5reactions
gothravencommented, Apr 30, 2019

I’m still having the same issue in 2019 elasticsearch-async==6.2.0, the pypi update is not done yet ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unclosed connector / client session when using asyncio
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external ...
Read more >
aiohttp has a warning message "Unclosed client session"
When i running my code, it's display a warning message: Unclosed client session. Anybody can give me some solutions about that? Thanks a...
Read more >
Using Asyncio with Elasticsearch
Receiving 'Unclosed client session / connector' warning?¶. This warning is created by aiohttp when an open HTTP connection is garbage collected.
Read more >
Unclosed client session warning : r/redditdev
I'm making a discord bot that take a random post from any subreddit using asyncpraw and it's working normally But the problem is...
Read more >
Source code for aiohttp.connector
_close_immediately() _warnings.warn(f"Unclosed connector {self!r}", ResourceWarning, source=self) context = { "connector": self, "connections": conns, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found