多阶段任务队列

taskue的Python项目详细描述


任务

多阶段任务队列使用Redis作为后端。

功能

  • 多个阶段。
  • 对定义数量的失效重试失败。
  • 捕获任务日志。
  • 任务可以用标签标记,因此它将只在具有相同标签的跑步者上运行。
  • 如果先前阶段的任何任务失败,则跳过任务。

安装

pip install taskue

开始

开始跑步
taskue runner start --redis-host <localhost> --redis-port <6379>

更多选项:

  • tags:运行程序标记,标记的任务将仅在具有其标记的运行程序上运行
  • timeout:运行程序超时,任务超时将覆盖它(默认为1小时)
  • run_untaged_tasks:允许运行程序运行未标记的任务(默认情况下启用)。
  • path:添加要包含的模块的路径。

工作原理
fromredisimportRedisfromtaskueimportTaskue,Tasktskue=Taskue(Redis())# define taskst1=Task()t1.execute(print,"Hello from task 1")t1.retries=3# retry up to 3 times on failure                         t2=Task()t2.timeout=5# set task timeout to 5t2.execute(print,"Hello from task 2")t3=Task()t3.skip_on_failure=True# skip this task if any task of the previous stage failedt3.execute(print,"Hello from task 3")

执行单个任务

# execute single tasktask_uid=tskue.run(t1)

或作为工作流执行多个任务

# run task t1 and task t2 in stage 1 and task t3 in stage 2workflow_uid=tskue.run_workflow([[t1,t2],[t3]])

Hint: All the tasks in the same stage run in parallel, and each stage starts when the previous stage finish.

cli

taskue --help
Usage: cli.py [OPTIONS] COMMAND [ARGS]...

Options:
  --redis-host TEXT     redis hostname
  --redis-port INTEGER  redis port
  --help                Show this message and exit.

Commands:
  runner
  task
  workflow

命令

  • runner
    • start:开始新的跑步者
  • task
    • list:列出所有任务
    • get:使用其uid获取任务信息
    • logs获取任务日志
    • delete删除任务
  • workflow
    • list:列出所有工作流
    • get:使用其uid获取工作流信息
    • logs获取工作流日志
    • delete删除工作流

待办事项

  • []检测死路人并重新安排其任务。
  • []添加更多文档和示例
  • []添加测试

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java GridBagLayout不填充区域   java Memozied Fibonacci未运行与常规Fibonacci解决方案   Java Web启动未启动问题   Java中异常和if-then的区别   java从命令提示符运行批处理文件获取错误   socket在Java中验证SSL证书的公共名称   如何在JAVA中检查字符串数组中的相等字   用java语言将音频文件转换成文本文件的语音识别   java为什么foo(1,2,3)没有传递给varargs方法foo(对象…)作为整数[]   java通过蓝牙将奇怪的数据从Arduino传输到Android   java ContainerRequestFilter获取空entitystream   java如何从安卓 studio中删除不兼容类型错误   基本Java错误   在Spring引导中使用REST API时发生java错误   javascript通过从SQL查询派生的URL打开页面