Open math-sasso opened 2 years ago
Though running scheduled task in a service is not well supported use case. I think you can use FastAPI to achieve scheduled task. In FastAPI, you can add startup and shutdown event to an app. You can schedule the task against a BackgroundScheduler in the startup and shutdown the scheduler in the shutdown event. https://fastapi.tiangolo.com/advanced/events/
@ssheng it is perfecly running iwth fastapi, The problem is that it is not running with bentoml, and that is the problem to me because I have a bento app that mounts a fastapi app
Describe the bug
In the code below I schedule a task to run every 3 seconds.
If I use FastAPI, we see the scheduled task result
uvicorn code:app
We can see the scheduled task
Tick! The time is: 2022-11-01 22:47:51.878470
Otherwise if we run it with bentoml, we can not schdule the tick method. It does not print Ticks.
bentoml serve code:service
To reproduce
No response
Expected behavior
Ticks should bre printed using bentoml.
Environment
bentoml: 1.0.8 pytohn: 3.8