异步线程:异步线程实用程序对象
asyncthreads的Python项目详细描述
AsyncThreads模块提供通用的线程设计模式和实用程序 用于异步和多线程编程。包括一根线 池和反应堆,它们结合在一起,创造了一个高度可靠的 并发事件处理系统。
项目链接
- Downloads: http://pypi.python.org/pypi/asyncthreads
- Documentation: https://bitbucket.org/agillis/asyncthreads/wiki/Home
- Project page: https://bitbucket.org/agillis/asyncthreads
- License: http://www.opensource.org/licenses/mit-license.php
安装
使用pip
Make sure python-pip is installed on you system. If you are using virtualenv, then pip is alredy installed into environments created by vertualenv. Run pip to install asyncthreads:
^{tt1}$
来自源
The asyncthreads package is installed from source using distutils in the usual way. Download the source distribution first. Un-tar the source tarball and run the following to install the package site-wide:
^{tt2}$
用法
使用threadpool和reactor就像创建实例和提交工作一样简单:
r = Reactor(ThreadPool(MIN_SIZE, MAX_SIZE)) r.start() r.call(handle_event, (transport, event_id)) r.call_later(300, five_min_sync_check, (param1, param2)) r.call_in_thread(background_task) r.call_in_thread_later(600, ten_min_async_check, (param1, param2)) r.shutdown()
有关详细信息,请参见documentation。
例如用法,请查看src中的examples和test目录。
要求
- Python 2.7 or greater
开发工具
开发工具仅用于执行开发工作和运行 测验。
- mercurial
- py.test
- pychecker