python 任务队列 huey_python的分布式任务huey如何实现异步化任务讲解

本文介绍了Python的轻量级任务队列Huey,它支持多线程任务执行、定时及周期性执行任务。Huey依赖redis作为默认队列后台,具有简单的API和易于理解的代码。文中详细讲解了Huey的安装、配置以及使用示例,包括任务的定义、worker参数、日志设置和结果存储。Huey还支持延迟执行和类似crontab的功能。
摘要由CSDN通过智能技术生成

本文我们来分享一个python的轻型的任务队列程序,他可以让python的分布式任务huey实现异步化任务,感兴趣的朋友可以看看。

一个轻型的任务队列,功能和相关的broker没有celery强大,重在轻型,而且代码读起来也比较的简单。

关于huey的介绍: (比celery轻型,比mrq、rq要好用 !)

a lightweight alternative.

written in python

no deps outside stdlib, except redis (or roll your own backend)

support for django

supports:

multi-threaded task execution

scheduled execution at a given time

periodic execution, like a crontab

retrying tasks that fail

task result storage

安装:

代码如下:

Installing

huey can be installed very easily using pip.

pip install huey

huey has no dependencies outside the standard library, but currently the only fully-implemented queue backend it ships with requires redis. To use the redis backend, you will need to install the python client.

pip install redis

Using git

If you want to run the very latest, feel free to pull down the repo from github and install by hand.

git clone

cd huey

python setup.py install

You can run the tests using the test-runner:

python setup.py test

关于huey的api,下面有详细的介绍及参数介绍的。

代码如下:

from huey import RedisHuey, crontab

huey = RedisHuey('my-app', host='redis.myapp.com')



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值