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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在javaswing中使用进度条,同时函数在繁重的进程中工作   SWIG(Java):如何调用带有void*out参数的函数?   java帮助解决算法问题   java,但我不想用try/catch块来包围语句!   可以从java类调用安卓类吗?   java流拆分器实现细节   java组织。莫基托。例外情况。滥用。无效使用MatcherException   java如何显示接收到的字符串?   java为什么这段代码不像JSR133建议的那样进入无限循环?   java BufferedReader readLine()从socket获取数据时冻结   java如何使用html表单发送的XML?   java RxJava与观察者代码的并行执行   我想使用CoreJava基于文本输入动态创建一个jpg图像   java如何在Mockito中模拟注入的bean?   java我的程序突然停止工作,我没有改变我记得的任何东西,现在它给出了第二个错误:javafx。fxml。加载异常   java树集排序错误   java RSA加密解密AES密钥并存储在文件中   Java将变量字符串[]与字符串混合在一个字符串数组中   如何在鼠标移动时重新绘制Java SWT应用程序?