import os
import threading
_lock_services=threading.Lock()
tmp_file="/tmp/txt.json"
update_time_sec=3300
with _lock_services:
# if file was created more the 50min ago
# here you can check if file was updated and update your cache variable
if os.path.getctime(tmp_file) < (time.time() - update_time_sec):
os.system("%s >%s" %("echo '{}'",tmp_file))
with open(tmp_file,"r") as json_data:
cache_variable = json.load(json_data)
为什么不想把程序分成几个部分:
下载器
解析器和保护程序
有成效的员工
您可以使用缓存变量来存储所需的值,这些值将在文件更新时更新。在
相关问题 更多 >
编程相关推荐