diff options
author | Bryan Newbold <bnewbold@archive.org> | 2021-03-29 20:39:17 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2021-03-29 20:39:19 -0700 |
commit | fc6ebef14cf3398ac1664b9f585d6ed5e7caf609 (patch) | |
tree | 4ce827ec41368209bbe61793108a6083742df5bd /fatcat_scholar/web.py | |
parent | b6ea443af3b1a304a964c19b45c4cbec9e751dc0 (diff) | |
download | fatcat-scholar-fc6ebef14cf3398ac1664b9f585d6ed5e7caf609.tar.gz fatcat-scholar-fc6ebef14cf3398ac1664b9f585d6ed5e7caf609.zip |
don't use async endpoints for sync implementations
Embarassingly, I didn't know this was an option in FastAPI! Knew that
running `await` on a function that was internally doing blocking calls
was really bad, but didn't know the framework had such a simple way to
avoid the problem.
This significantly resolves operational concerns with the current
service.
Diffstat (limited to 'fatcat_scholar/web.py')
-rw-r--r-- | fatcat_scholar/web.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py index 9664474..005c22b 100644 --- a/fatcat_scholar/web.py +++ b/fatcat_scholar/web.py @@ -130,7 +130,7 @@ class HitsModel(BaseModel): @api.get("/search", operation_id="get_search", response_model=HitsModel) -async def search(query: FulltextQuery = Depends(FulltextQuery)) -> FulltextHits: +def search(query: FulltextQuery = Depends(FulltextQuery)) -> FulltextHits: hits: Optional[FulltextHits] = None if query.q is None: raise HTTPException(status_code=400, detail="Expected a 'q' query parameter") @@ -237,7 +237,7 @@ async def web_help(request: Request, lang: LangPrefix = Depends(LangPrefix)) -> @web.get("/search", include_in_schema=False) -async def web_search( +def web_search( request: Request, response: Response, query: FulltextQuery = Depends(FulltextQuery), @@ -246,7 +246,7 @@ async def web_search( ) -> Any: if content.mimetype == "application/json": - return await search(query) + return search(query) hits: Optional[FulltextHits] = None search_error: Optional[dict] = None status_code: int = 200 |