dmontagu / fastapi-utils

Reusable utilities for FastAPI
MIT License
1.89k stars 165 forks source link

[QUESTION] #244

Closed keyouth0 closed 3 years ago

keyouth0 commented 3 years ago

Description I need to asynchronously get some config from my config server using repeated task.

I declare a function to asynchronously get config decorated with the @app.on_event("startup") and @repeat_every. like this: @app.on_event("startup") @repeat_every(seconds=60) async def listener_task() -> None:

And I use the config in another function decorated with the @app.on_event("startup"). like this: @app.on_event("startup") async def init_orm() -> None:

How can I ensure the first time I get the config before using the config.

Additional context Add any other context or screenshots about the feature request here.