qdrant / qdrant/qdrant-client

Calling get_collection fails with qdrant_client.http.exceptions.ResponseHandlingException: Event loop is closed

Open
#863 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
304
Avg merge
2d 9h
Merged PRs (30d)
37

Description

Hello,

await client.get_collection("collection_name")

Fails with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api_client.py", line 178, in send_inner
    response = await self._async_client.send(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1674, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_client.py", line 1776, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
    raise exc from None
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 229, in handle_async_request
    await self._close_connections(closing)
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 345, in _close_connections
    await connection.aclose()
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/connection.py", line 173, in aclose
    await self._connection.aclose()
  File "/usr/local/lib/python3.13/site-packages/httpcore/_async/http11.py", line 258, in aclose
    await self._network_stream.aclose()
  File "/usr/local/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
    await self._stream.aclose()
  File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
    self._transport.close()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1202, in close
    super().close()
    ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 865, in close
    self._loop.call_soon(self._call_connection_lost, None)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 829, in call_soon
    self._check_closed()
    ~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 552, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<python-input-7>", line 1, in <module>
    asyncio.run(knowledgebase.client.get_collection("knowledgebase_v1"))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/async_qdrant_client.py", line 1999, in get_collection
    return await self._client.get_collection(collection_name=collection_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/async_qdrant_remote.py", line 2267, in get_collection
    await self.http.collections_api.get_collection(collection_name=collection_name)
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api/collections_api.py", line 945, in get_collection
    return await self._build_for_get_collection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        collection_name=collection_name,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api_client.py", line 151, in request
    return await self.send(request, type_)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api_client.py", line 168, in send
    response = await self.middleware(request, self.send_inner)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api_client.py", line 200, in __call__
    return await call_next(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/qdrant_client/http/api_client.py", line 180, in send_inner
    raise ResponseHandlingException(e)
qdrant_client.http.exceptions.ResponseHandlingException: Event loop is closed

Other methods, that I am using, like search, collection_exists, etc. works.

It fails even in fresh terminal sessions wrapped into asyncio.run.

It fails only on production! on my local PC with same config that comand works.
There is no difference in setup.

Thanks for help

Also:
this code from AsyncQdrantFastembedMixin add method.:
image
hides real issue,
I found that get_collection fails by digging into sentry log:
image
that happen because qdrant client tries to create collection no matter what, and hides exception from rise.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported asyncio.run call to reproduce get_collection, then read async_qdrant_client.py around get_collection and the AsyncQdrantFastembedMixin add method. Compare the get_collection failure with the working search and collection_exists calls, and trace the ResponseHandlingException through http/api_client.py. Done means the production-only failure is reproducible and the underlying exception is no longer hidden by the add path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.