目前,我在heroku有一个部署的应用程序,它使用流光框架进行数据分析。然而,页面打开速度非常慢,因为每次用户打开该网站时,它都会开始下载CSV数据。
因此,我的目标是原子化一项任务,下载CSV数据,使网站变得轻量级。是否有任何方法可以使用例如,调度库到流媒体下载CSV数据每天?
发布于 2022-04-05 15:32:51
我不认为有解决办法只使用Streamlit。
我也遇到了同样的问题,并通过创建另一个通过cron运行的脚本来修复它。
你的剧本:
# create a python script that will download the
# csv data
# bear in mind, what I write is an example,
# since it is a Python script, you can do whatever you want ;)
def create_csv():
with open("/path/to/csv", "w") as f:
f.write("a,b,c\n1,2,3")
if __name__ == "__main__":
create_csv()并且让这个脚本每小时运行一次(例如):
crontab -e在打开的文件中:
0 * * * * cd /path/to/script && python script.py您可以检查cron语法这里。
发布于 2022-10-23 14:22:37
https://stackoverflow.com/questions/64508558
复制相似问题