Fastapi: [QUESTION] Support for concurrent dataframe operations with async await

Created on 23 Dec 2020  路  4Comments  路  Source: tiangolo/fastapi

Support for concurrent Panda Dataframe GET access

Does FastAPI support concurrent Dataframe read/GET access to various different columns for validation checks, where I am not expecting any dependencies between the columns.

i.e after df is created, instead of sequentially calling

check_for_NA
check_account_types
check_duplicates

how to async trigger these above and collect results are ready and perform a AND function

Screenshot 2020-12-23 at 02 03 20

Environment

  • OS: macOS: 11.1 Big Sur
  • FastAPI Version fastapi 0.63.0:

    (.venv) pyth3 --version
    Python 3.9.1

question

All 4 comments

Firstly, Fastapi does not have any integration with pandas.

To answer your question though, you could run those operations in a thread pool, and perform the AND once they all complete? I would be surprised if this actually improved performance though

@Mause thanks I know there is no integration with Pandas, but based on the async await nature that FastApi handles I thought I'd ask to see if there are benefits, if so how to approach it.

Pandas doesn't have async support, so your only option here is to use threads, though as I said, it's not guaranteed that this will give a performance improvement

This is not related in any way to fastapi, but it's an interesting question. I would encourage you to post this question on a site like StackOverflow

Was this page helpful?
0 / 5 - 0 ratings