-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make search_companies async #12
Conversation
@sanders41 is attempting to deploy a commit to the bruhbruhroblox's projects Team on Vercel. A member of the Team first needs to authorize it. |
results = [] | ||
for result in hits: | ||
results.append(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this because it doesn't look to be doing anything, results
is never used. Or maybe I'm missing something?
You're correct in assuming the As for
Forgive my amateur understanding of asynchrnous Python if this is not the case, but won't FastAPI run asychronously regardless of whether Meilisearch has an asynchronous client (especially with multiple workers)? If there is a benefit though (even a nominal one), I'd be willing to merge this. Thank you for contributing! |
For a "regular" I have not done any specific FastAPI benchmarking but typically awaiting an async def would be faster than a thread pool. I do have some benchmarks you can see here and the async search was significantly faster when handling multiple requests. This said another option would be to change |
Understood, thank you! I will run a test and merge this. |
I got two different errors. The first was easy to fix. In The second problem was that Here is the (minified) code before and after. def _prepare_meilisearch()
if not indexes or "companies" not in [index.uid for index in indexes]:
task = client.create_index("companies", {"primaryKey": "cik"})
client.wait_for_task(task.task_uid, timeout=None)
_prepare_meilisearch() import asyncio
async def _prepare_meilisearch()
if not indexes or "companies" not in [index.uid for index in indexes]:
await client.create_index("companies", primary_key="cik")
asyncio.new_event_loop().run_until_complete(_prepare_meilisearch()) I'll add these commits and merge the whole thing, but I just want to make sure I'm following best practices. |
Co-authored-by: Paul Sanders <psanders1@gmail.com>
The
search_filers
route is async however the call to Meilisearch for the search is not. This makes the call to Meilisearch async in order to not block the event loop.