# What is the best practice to use v4 python client for query with fastapi(or other async python framework)

**URL:** <https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245>\
**Category:** Support\
**Created:** [January 18, 2024, 7:26am UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245 "2024-01-18T07:26:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [January 18, 2024, 7:26am UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/1 "2024-01-18T07:26:22Z")

</div>

> **[Python (Client v4) | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/client-libraries/python#thread-safety)**
>
> The Python client v4 is currently in beta. Please note the following:

Since v4 doesn’t support async method, I am planning to wrap it with asyncio.to\_thread.

Can I assume I can use the same client form multithread for query?  
if I don’t use batch ops is that safe to use the same client for update or insert ops?  
Is there any connection pool under the hood of v4 client?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [January 18, 2024, 11:56am UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/2 "2024-01-18T11:56:39Z")

</div>

Hi!

That should work. Also, while initiating the connection, you can use `skip_init_checks=True` in order to avoid initial checks for the connection and make it faster.

Here the code for this parameter:

> <https://github.com/weaviate/weaviate-python-client/blob/d5b6170b7f6f08fc46bad7709e982f4a51cc0976/weaviate/connect/v4.py#L125>

That for querying. While for importing using batch, you should avoid using multiple clients.

---

<div class="post-metadata">

**Author:** ![DaveCuthbert](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/davecuthbert/32/438_2.png) [@DaveCuthbert](https://forum.weaviate.io/u/DaveCuthbert)\
**Post date:** [January 18, 2024, 3:03pm UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/3 "2024-01-18T15:03:27Z")

</div>

Have you tried the latest v4 beta (4.4b8)? It does support async.

---

<div class="post-metadata">

**Author:** ![Dirk](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dirk/32/46_2.png) [@Dirk](https://forum.weaviate.io/u/Dirk)\
**Post date:** [January 19, 2024, 4:27am UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/4 "2024-01-19T04:27:28Z")

</div>

> Have you tried the latest v4 beta (4.4b8)? It does support async.

It uses async for concurrent batching in the background, but there is no support for users doing async queries themselves. We did some preparation for real async support (switching to httpx, and some plumbing), but it will most likely be added for users after v4 is stable.

> Can I assume I can use the same client form multithread for query?  
> if I don’t use batch ops is that safe to use the same client for update or insert ops?

We have not tried it, but I think insert/update should be ok. But query is not.

> Is there any connection pool under the hood of v4 client?

for insert()/update() yes, we use httpx with a session pool.

---

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [January 19, 2024, 6:51pm UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/5 "2024-01-19T18:51:18Z")

</div>

I know async batch import is supported.  
what I said is async query and other operation

---

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [January 19, 2024, 6:55pm UTC](https://forum.weaviate.io/t/what-is-the-best-practice-to-use-v4-python-client-for-query-with-fastapi-or-other-async-python-framework/1245/6 "2024-01-19T18:55:02Z")

</div>

> We have not tried it, but I think insert/update should be ok. But query is not.

So I must use different client when using multi-thread for query?
