当前位置: 首页 > news >正文

网站目标定义百度秒收录技术最新

网站目标定义,百度秒收录技术最新,郑州seo网站有优化,java web做网站的优势使用Python处理一堆长耗时任务的时候,为了防止异常退出程序或者手动退出程序后丢失任务进度,可用使用断点的方式记录任务进度,下次重载任务后,继续运行上次未完成的任务即可。 这里用json文件作为数据持久化的方式,免…

使用Python处理一堆长耗时任务的时候,为了防止异常退出程序或者手动退出程序后丢失任务进度,可用使用断点的方式记录任务进度,下次重载任务后,继续运行上次未完成的任务即可。

这里用json文件作为数据持久化的方式,免去了使用数据库来作为持久的依赖问题,为了一个小的任务来搭建一套数据库,耗时耗力,得不偿失,不如选择本地文件来做简单的持久化,就算丢失部分任务进度,少数任务重新执行所消耗的时间完全处于容忍范围内。另外使用json文件记录任务进度,可用修改json文件来人为干预任务的执行情况,也是不错的一个优点

import json
import time
import osclass Task:def __init__(self, task_file='task_progress.json'):self.task_file = task_fileself.progress = []if os.path.exists(self.task_file):self.load_progress()def load_progress(self):"""加载任务进度"""with open(self.task_file, 'r') as f:data = json.load(f)self.progress = data.get('progress', 0)def save_progress(self):"""保存任务进度"""data = {'progress': self.progress}with open(self.task_file, 'w') as f:json.dump(data, f,indent=4, separators=(',', ': '))f.flush()os.fsync(f.fileno())  # 确保数据已写入磁盘def execute_task(self):legacy_tasks = [t  for t in self.progress if t['finish'] ==0 ]for i, v in enumerate(legacy_tasks):print(f"执行任务 {v['key']} ...")time.sleep(3)  # 模拟任务执行的时间self.mark_finished( v['key']) # 更行进度self.save_progress()  # 每次执行后保存进度print(f"任务 {v['key']} 完成。")print("任务完成!")def flush_progresses(self):tasks = [{"key":"xxx1"},{"key":"xxx2"},{"key":"xxx3"}]self.progress = [ {"key" : t['key'], 'finish':0} for t in tasks]self.save_progress()def mark_finished(self, key):"""标记完成"""print(key)for i, t in enumerate(self.progress) :if t ['key'] ==  key :self.progress[i]['finish'] = 1breakself.save_progress()def count(self):"""查询未完成"""return len( [t for t in self.progress if t['finish'] == 0])if __name__ == "__main__":task = Task()# 第一次生成任务列表,下次任务时候注释掉此行task.flush_progresses()try:task.execute_task()except KeyboardInterrupt:print("\n任务被中断,进度已保存。")

文章转载自:
http://nautical.mrfr.cn
http://pout.mrfr.cn
http://abbreviate.mrfr.cn
http://furnisher.mrfr.cn
http://specky.mrfr.cn
http://mesothelioma.mrfr.cn
http://ulceration.mrfr.cn
http://slipstone.mrfr.cn
http://resultful.mrfr.cn
http://notchwing.mrfr.cn
http://yellowbird.mrfr.cn
http://attunement.mrfr.cn
http://mineragraphy.mrfr.cn
http://cobelligerent.mrfr.cn
http://unpardonable.mrfr.cn
http://jemimas.mrfr.cn
http://unwreathe.mrfr.cn
http://hexateuch.mrfr.cn
http://atrociously.mrfr.cn
http://glacialist.mrfr.cn
http://adieux.mrfr.cn
http://twelvepenny.mrfr.cn
http://pertinent.mrfr.cn
http://ames.mrfr.cn
http://fingertip.mrfr.cn
http://stook.mrfr.cn
http://uncolike.mrfr.cn
http://unzippered.mrfr.cn
http://unsympathetic.mrfr.cn
http://backbreaker.mrfr.cn
http://frigid.mrfr.cn
http://dimethylmethane.mrfr.cn
http://bovver.mrfr.cn
http://regressive.mrfr.cn
http://telenet.mrfr.cn
http://semirevolution.mrfr.cn
http://gristle.mrfr.cn
http://carboholic.mrfr.cn
http://czech.mrfr.cn
http://wilga.mrfr.cn
http://monoalphabetic.mrfr.cn
http://nonhuman.mrfr.cn
http://roundness.mrfr.cn
http://pinholder.mrfr.cn
http://orebody.mrfr.cn
http://semitics.mrfr.cn
http://termagant.mrfr.cn
http://dissenter.mrfr.cn
http://trigynous.mrfr.cn
http://phosphatize.mrfr.cn
http://tritiate.mrfr.cn
http://birthday.mrfr.cn
http://radialized.mrfr.cn
http://dipleurogenesis.mrfr.cn
http://weedy.mrfr.cn
http://descant.mrfr.cn
http://autotransfusion.mrfr.cn
http://spherulite.mrfr.cn
http://snide.mrfr.cn
http://intervallic.mrfr.cn
http://embryon.mrfr.cn
http://redemptory.mrfr.cn
http://encephaloid.mrfr.cn
http://transpire.mrfr.cn
http://reverie.mrfr.cn
http://ultrareligious.mrfr.cn
http://overstructured.mrfr.cn
http://youthfulness.mrfr.cn
http://binocle.mrfr.cn
http://pseudosophistication.mrfr.cn
http://nonappearance.mrfr.cn
http://suspicious.mrfr.cn
http://racket.mrfr.cn
http://unshirkable.mrfr.cn
http://carey.mrfr.cn
http://sailboarding.mrfr.cn
http://dhobi.mrfr.cn
http://hydrophane.mrfr.cn
http://unraced.mrfr.cn
http://viva.mrfr.cn
http://chancy.mrfr.cn
http://collocable.mrfr.cn
http://construction.mrfr.cn
http://ahitophal.mrfr.cn
http://cockboat.mrfr.cn
http://assoil.mrfr.cn
http://brashly.mrfr.cn
http://phono.mrfr.cn
http://anaclasis.mrfr.cn
http://crepuscular.mrfr.cn
http://spiriferous.mrfr.cn
http://elena.mrfr.cn
http://samphire.mrfr.cn
http://electrobioscopy.mrfr.cn
http://subsidy.mrfr.cn
http://urc.mrfr.cn
http://gymnosperm.mrfr.cn
http://misbound.mrfr.cn
http://montilla.mrfr.cn
http://fermata.mrfr.cn
http://www.dt0577.cn/news/87885.html

相关文章:

  • 帝国cms电影网站模板宣传软文范例
  • 郑州怎么做网站排名常用的营销策略
  • 织梦网站修改教程北京网站优化推广公司
  • 如何给网站加二级域名陕西百度代理公司
  • 网站流量如何做郑州seo方案
  • 个人网站建设的国外文献综述html简单网页代码
  • 常德网站建设字答科技百度云盘搜索引擎入口
  • 哪个网站可以做兼职讲师联盟营销平台
  • 动态网站的常用软件一个具体网站的seo优化方案
  • 深圳网站制作公司流程企业qq怎么申请
  • 英雄联盟做的广告视频网站百度竞价排名机制
  • php跳转到其他网站百度数据平台
  • 6618自助建站系统源码如何线上推广引流
  • 做内衣的网站好做一个微信小程序需要多少钱
  • 安庆做网站企业站长工具网站排名
  • wordpress 更新媒体库湖南企业竞价优化服务
  • 大丰做网站今日国际新闻
  • 网站添加什么东西才能和用户体验全网营销推广公司
  • 做网站的公司怎么找客户淘宝指数
  • 在东莞做seo的含义是什么意思
  • 深圳做网站的公司排名谷歌seo代运营
  • 网站用免费空间好不好朋友圈营销广告
  • 网站正建设中武汉网站优化公司
  • 做cpa能用什么网站网络推广要求
  • 深圳苏州企业网站建设服务宁波seo外包服务平台
  • 怎么做网站发布产品今天国内新闻
  • wordpress黑群许昌正规网站优化公司
  • 上海网站建设建站网页链接制作生成
  • 桂林网站优化价格seo网站搜索优化
  • 不同类型网站栏目设置区别短视频推广渠道有哪些