typesense-python icon indicating copy to clipboard operation
typesense-python copied to clipboard

Support for Asynchronous Environments?

Open dhrumilp15 opened this issue 3 years ago • 6 comments

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 avatar Jul 07 '21 23:07 dhrumilp15

@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.

kishorenc avatar Jul 12 '21 02:07 kishorenc

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.

vd2org avatar Jul 17 '21 12:07 vd2org

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

vd2org avatar Jul 17 '21 12:07 vd2org

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.

haoyun avatar Dec 24 '21 02:12 haoyun

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

trollfot avatar Dec 19 '23 19:12 trollfot

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.

mgraczyk avatar Feb 07 '24 20:02 mgraczyk