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

remove create_sync_endpoint, run sync functions in background thread #471

Merged
merged 3 commits into from
Oct 2, 2022

Conversation

geospatial-jeff
Copy link
Collaborator

@geospatial-jeff geospatial-jeff commented Oct 2, 2022

Description:
Remove some code duplication by removing create_sync_endpoint. Instead wrap synchronous function calls in a decorator which executes them asynchronously through a background thread using starlette.concurrency.run_in_threadpool. This means all endpoint handlers used by async or sync backends will be executed asynchronously.

FastAPI also executes synchronous endpoint handlers in background threads, so this should behave the same as before but with one less code path.

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@geospatial-jeff geospatial-jeff merged commit d1daa92 into master Oct 2, 2022
@geospatial-jeff geospatial-jeff deleted the sync-to-async branch October 2, 2022 20:11
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.

1 participant