Skip to main content

A Python executor for XXL-jobs

Project description

xxl-jobs 的python客户端实现

Package version Supported Python versions Coverage

使用pyxxl可以方便的把Python写的方法注册到XXL-JOB中,使用XXL-JOB-ADMIN管理Python定时任务和周期任务

实现原理:通过XXL-JOB提供的RESTful API接口进行对接

已经支持的功能

  • 执行器注册到job-admin
  • task注册,类似于flask路由装饰器的用法
  • 任务的管理(支持在界面上取消,发起等操作,任务完成后会回调admin)
  • 所有阻塞策略的支持
  • 异步支持(推荐)

待实现

  • 自定义日志 和 界面上查看日志

适配的XXL-JOB版本

  • XXL-JOB:2.3.0

如遇到不兼容的情况请issue告诉我XXL-JOB版本我会尽量适配

如何使用

pip install pyxxl
import asyncio

from pyxxl import ExecutorConfig, PyxxlRunner

config = ExecutorConfig(
    xxl_admin_baseurl="http://localhost:8080/xxl-job-admin/api/",
    executor_app_name="xxl-job-executor-sample",
    executor_host="172.17.0.1",
)

app = PyxxlRunner(config)

@app.handler.register(name="demoJobHandler")
async def test_task():
    await asyncio.sleep(5)
    return "成功..."

# 如果你代码里面没有实现全异步,请使用同步函数,不然会阻塞其他任务
@app.handler.register(name="xxxxx")
def test_task3():
    return "成功3"


app.run_executor()

更多示例和接口文档请参考 PYXXL文档 ,具体代码在example文件夹下面

开发人员

下面是开发人员如何快捷的搭建开发调试环境

启动xxl的调度中心

./init_dev_env.sh

启动执行器

poetry install
# 修改app.py中相关的配置信息,然后启动
poetry run python example/app.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxxl-0.2.2.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

pyxxl-0.2.2-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file pyxxl-0.2.2.tar.gz.

File metadata

  • Download URL: pyxxl-0.2.2.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pyxxl-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b11480edb647b6ba2f095bd3dac264177bdb1cce78e5f19d384f76bc8f881b81
MD5 aa2351bddb43fb3bfa2931e396ebb345
BLAKE2b-256 c6745ba0e1453e42ec4ff1565637542b96c7fefe4cc65e77d9ae2a187589d49f

See more details on using hashes here.

File details

Details for the file pyxxl-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: pyxxl-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for pyxxl-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8409bcf12e456be26ca491c7c07868391b2a910dc3c9b0f2a1faa6eadd576a1
MD5 14ab1d20ef35fe4bd626a02ce46de786
BLAKE2b-256 cc590415fdb5f65628547586d3df503e7d50b0b8401af9e95b547b8e44d7a3a0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page