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

Rewrite OdkCentral.py to be async #224

Closed
spwoodcock opened this issue Jan 25, 2024 · 0 comments · Fixed by #253
Closed

Rewrite OdkCentral.py to be async #224

spwoodcock opened this issue Jan 25, 2024 · 0 comments · Fixed by #253
Labels

Comments

@spwoodcock
Copy link
Member

spwoodcock commented Jan 25, 2024

Is your feature request related to a problem? Please describe.

  • Most of the OdkCentral code is network IO bound.
  • Using async code is much more efficient for this use case, as code is executed in an event loop: while waiting for the response from some IO operation, another process can be executed (essentially in parallel), instead of locking the thread waiting for the response.
  • All modern web APIs in Python are ASGI now, so the default is async upstream. Usage of a sync library in an async framework is problematic.

Describe the solution you'd like

  • Update requests --> aiohttp or httpx.
  • Rewrite all class methods + functions to be async:
    • Add async def everywhere.
    • await database calls.
    • await network operations.

Describe alternatives you've considered

  • Keeping everything as synchronous code, as it's a lot of work to update all of our dependent libraries.

Additional considerations

  • This should wait until a good point when we have time to refactor lots of code.
@spwoodcock spwoodcock changed the title Rewrite code to be async Rewrite OdkCentral.py to be async Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant