Skip to content
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

Fix async clash with dask #12

Merged
merged 1 commit into from Mar 3, 2020
Merged

Conversation

lsetiawan
Copy link
Contributor

Overview

This PR fixes #7.

Problem

It appears that there was a clash/confusion between the uvicorn event loop and the dask distributed event loop. When using async in a FastAPI app, this method will be sent to the uvicorn event loop. So the request for individual chunks were processed concurrently. Each dask compute becomes blocking and is only processed by one worker which I think is part of the uvicron event loop.

Solution

To allow dask to actually compute in parallel the async and await for get_key should be remove, which frees up this method to use the compute within dask distributed event loop rather than the uvicorn event loop.

@jhamman jhamman requested a review from andersy005 March 3, 2020 21:41
@andersy005
Copy link
Contributor

I ran a quick smoke test locally, and things seem to be moving in the right direction:

With @lsetiawan changes, I am noticing some asynchronicity + parallelism on the server side. I am all for merging this for now, and I will work on getting #10 done so that we can run some benchmarks.

  • This PR:

Screen Shot 2020-03-03 at 3 25 27 PM

  • Master
    Screen Shot 2020-03-03 at 3 22 24 PM

@andersy005
Copy link
Contributor

Thank you for the clarification, too! I am amazed by how easy of a fix this is. I am learning quite a lot about Python's async features :)

@jhamman jhamman merged commit d59221e into xpublish-community:master Mar 3, 2020
@lsetiawan lsetiawan deleted the fix_async branch March 4, 2020 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support async key retrieval
3 participants