Skip to main content

一个极简的分布式任务模块

Project description

Job Hive

PyPI version

基于Redis实现的轻量级分布式任务队列系统

🚀 功能特性

  • 支持任务推送、执行生命周期管理
  • 提供Redis队列实现(支持密码认证)
  • 上下文管理器简化资源管理
  • 支持任务批处理(示例中含单任务推送)

📦 安装依赖

目前仅支持Python3.10+,于 0.1.3 版本在原来 Redis 的基础上,加入简易版本的 Kafka 支持

使用 redis

pip install job_hive[redis]

使用 kafka

pip install job_hive[kafka]

🛠️ 使用示例

from job_hive import HiveWork
from job_hive.queue import RedisQueue

with HiveWork(queue=RedisQueue(
        name="test",
        host="your_redis_host",
        password="your_password"
)) as work:
    # 使用work 对象进行任务推送提交到任务池
    jobs = [work.push(print, f"hello {i}") for i in range(5)]
    for job in jobs:
        print(job.status)
    # 启动工作模式接收任务
    work.work()

⚙️ 配置说明

from job_hive.queue import RedisQueue, KafkaQueue

RedisQueue(
    name="队列名称",  # 必填
    host="localhost",  # 默认localhost
    port=6379,  # 默认端口
    password=None,  # 密码(可选)
    db=0  # 数据库编号,默认为0
)

KafkaQueue(
    topic_name='test', # 主题
    servers='1Panel-kafka-3wvJ:9092' # Kafka 服务
)

🤝 贡献指南

  1. Fork本仓库
  2. 创建特性分支(git checkout -b feature/AmazingFeature)
  3. 提交修改(git commit -m 'Add some AmazingFeature')
  4. 推送分支(git push origin feature/AmazingFeature)
  5. 发起Pull Request

📄 许可证

MIT License

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

job_hive-0.1.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

job_hive-0.1.4-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file job_hive-0.1.4.tar.gz.

File metadata

  • Download URL: job_hive-0.1.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

File hashes

Hashes for job_hive-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4b6556af15873117b7801e9458299cbd4f86068a60760b8331897c1fcdb69f31
MD5 d727a29605589fff57d41df23b08fbcf
BLAKE2b-256 eb554e4c33e2de077a0a47b0d776d91e385e4582acbb19218333658fe7c957d4

See more details on using hashes here.

File details

Details for the file job_hive-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: job_hive-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

File hashes

Hashes for job_hive-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 93c8e882e3ab57e0fed8b6c1447ca17d75fe74819d7a7aeeb88cbe016d969034
MD5 8c93605afc1038d0faa9e8eed4d07d88
BLAKE2b-256 6da08f8fec964b56df61201b5798092ad0db9dd9ac72cf05d9bf67c891322ea7

See more details on using hashes here.

Supported by

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