Hydra
Hydra是基于生产者-消费者模型的一个多进程任务引擎。
海德拉是希腊神话中的九头蛇怪,砍掉一个头,马上会再生出两个,最后被海格力斯所打败。
命名为海德拉的原因很简单,因为语言是python,有多个头的python,自然就是传说中的九头蛇啦。
特性
无第三方依赖库,轻量级
运行效率高,充分利用多核
简单易于上手
依赖
python 2.7
运行环境
windows
ubuntu(其它*unix没有测试)
特别说明,不支持mac os x,因为使用到了multiprocessing模块中的queue,其中一个方法,qsize,mac os x并没有实现。
qsize()
Return the approximate size of the queue. Because of multithreading/multiprocessing semantics, this number is not reliable.
Note that this may raise NotImplementedError on Unix platforms like Mac OS X where sem_getvalue() is not implemented.
安装
git clone https://github.com/Hugh-wong/hydra.git
如何应用
定义一个取任务的函数
def retrieve_items(need_count):
pass
该函数从文件/数据库/缓存等取出来数据(注意如果开启