typesense-python
typesense-python copied to clipboard
Support for Asynchronous Environments?
Description
This is more of a question/enhanchement! Does typesense-python have support for asynchronous environments?
By this I mean:
- Are functions that change search indices (save/delete objects, creating/deleting a new index) blocking?
- Algolia is synchronous "by design" and many index functions place tasks into a queue to be processed - does Typesense do something similar?
@dhrumilp15 Typesense backend API is synchronous in nature. For a large number of use cases this is more convenient as you get to know the result of an operation immediately, instead of having to make one more API call to look up the status.
The Python client is also synchronous, so when you call a method on the client, it will block until the response arrives or the operation times out.
Can you please help me understand how asynchronous operations will be helpful to your use case? That will help us prioritize future work.
This does not mean that the API itself has to be asynchronous. This means support for asyncio for using the api in asynchronous applications like FastAPI.
You can take a look at my async library for CouchDB, which is designed in much the same way as yours, but for an async environment:
https://github.com/vd2org/wheelchair
I found a project https://github.com/devtud/aio_typesense that does the job.
i hope, howevr, async/await
will be officially supported in typesens-python
.
I am poking a dead horse, here, but I started my own implementation, based on aio_typesense that I updated and heavily modified.
https://github.com/trollfot/typesense_aio
Feel free to jump in
I forked to add async in such a way that it will be easy for me to keep the fork up to date:
https://github.com/Quilt-AI/typesense-python
This doesn't require many changes to the current codebase. Supporting both at the same time would be slightly more annoying/complicated but definitely doable.
Others are welcome to fork or use it. I think httpx
or aiohttp
like I have done is the way to go.