python线程池和调度执行器
breadpool的Python项目详细描述
[![构建状态](https://travis-ci.org/chamilad/breadpool.svg?branch=master)(https://travis-ci.org/chamilad/breadpool)
[![覆盖状态](https://coveralls.io/repos/chamilad/breadpool/badge.svg?branch=master&service=github?dd=gg)](https://coveralls.io/github/chamilad/breadpool?分支=主)
[![文档状态](https://readthedocs.org/projects/breadpool/badge/?版本=最新](http://breadpool.readthedocs.org/en/latest/?徽章=最新)
[![PYPI版本](https://badge.fury.io/py/breadpool.svg)(https://badge.fury.io/py/breadpool)
\breadpool
是的,编写自己的实现是一个简单的代码,不过,如果它们是“pip安装”的话,那么就容易多了。
breadpool可以从python包索引安装。
``bash
`pip install breadpool
````
`thread pool
`threadpool类是一个简单的线程池实现。它最初将创建一组工作线程,在分配任务时,工作线程将接管并执行任务。
如果希望线程在主线程终止时立即终止,则为true。默认情况下,此值设置为False
4-polling\u timeout是工作线程阻塞性等待任务队列
“
thread\u pool=threadpool(5,“customthreadpool”,polling\u timeout=1)
````
breadpool提供了名为“easytask”的“abstractrunnable”类的简单实现,该类接受函数作为要执行的任务。
``python
来自breadpool.pool import threadpool,easytask
time.sleep(random.randint(1,5))
et=easytask(func_test)
thread pool=threadpool(5,“customthreadpool”,daemon=true)
线程池.队列(et)
````
您可以扩展“abstractrunnable”类并编写自己的任务实现。
``python
from breadpool.pool import abstractrunnable
class customtask(abstractrunnable):
def execute(self):
##scheduledjobexecutor
这是“abstractrunnable”类型任务的简单调度执行器。它将以至少给定的时间间隔周期性地重复执行给定的任务。
轮询超时=20)
counter_queue=queue()
scheduled_executor=scheduledjobexecutor(
easytask(lambda(l):counter_queue.put(l),“test%s”%time.time()),
thread_pool,
5,
“customscheduledexecutor”)
scheduled executor.start()
….
scheduledexecutor.terminate()
````
python支持
breadpool仅支持python 2.7(目前)。
附加链接
1。阅读文档-http://breadpool.readthedocs.org/en/latest/
2.pypi-https://pypi.python.org/pypi/breadpool
[![覆盖状态](https://coveralls.io/repos/chamilad/breadpool/badge.svg?branch=master&service=github?dd=gg)](https://coveralls.io/github/chamilad/breadpool?分支=主)
[![文档状态](https://readthedocs.org/projects/breadpool/badge/?版本=最新](http://breadpool.readthedocs.org/en/latest/?徽章=最新)
[![PYPI版本](https://badge.fury.io/py/breadpool.svg)(https://badge.fury.io/py/breadpool)
是的,编写自己的实现是一个简单的代码,不过,如果它们是“pip安装”的话,那么就容易多了。
breadpool可以从python包索引安装。
``bash
`pip install breadpool
````
`thread pool
`threadpool类是一个简单的线程池实现。它最初将创建一组工作线程,在分配任务时,工作线程将接管并执行任务。
如果希望线程在主线程终止时立即终止,则为true。默认情况下,此值设置为False
4-polling\u timeout是工作线程阻塞性等待任务队列
“
thread\u pool=threadpool(5,“customthreadpool”,polling\u timeout=1)
````
breadpool提供了名为“easytask”的“abstractrunnable”类的简单实现,该类接受函数作为要执行的任务。
``python
来自breadpool.pool import threadpool,easytask
et=easytask(func_test)
thread pool=threadpool(5,“customthreadpool”,daemon=true)
线程池.队列(et)
````
您可以扩展“abstractrunnable”类并编写自己的任务实现。
``python
from breadpool.pool import abstractrunnable
class customtask(abstractrunnable):
def execute(self):
##scheduledjobexecutor
这是“abstractrunnable”类型任务的简单调度执行器。它将以至少给定的时间间隔周期性地重复执行给定的任务。
轮询超时=20)
counter_queue=queue()
scheduled_executor=scheduledjobexecutor(
easytask(lambda(l):counter_queue.put(l),“test%s”%time.time()),
thread_pool,
5,
“customscheduledexecutor”)
scheduled executor.start()
….
scheduledexecutor.terminate()
````
python支持
breadpool仅支持python 2.7(目前)。
附加链接
1。阅读文档-http://breadpool.readthedocs.org/en/latest/
2.pypi-https://pypi.python.org/pypi/breadpool