Skip to content

Turn the External Connection health check methods into async methods #1561

@davinotdavid

Description

@davinotdavid

After #1509 gets merged we will now have External Connection health check methods which is great ...except that they all run synchronously and can take a long time.

It would be nice to change it to be async with asyncio.gather!

Paraphrasing @MelissaAutumn here:

If you do make this async you'll have to make every other function that calls it async. If it's just a view function that calls it, then that'll be okay since fastapi says it automatically handles async view functions.

Ah asyncio.gather should be similar to Promises.all afaik

https://docs.python.org/3/library/asyncio-task.html#asyncio.gather

You'll basically just build a loop of the async tasks, and results = await asyncio.gather(tasks, return_exceptions=True) at the end.

In order to support the update, you'll need to punt essentially the loop's contents into a new function. And that new function will be the task you gather up to run async.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovements on existing functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions