异步线程:异步线程实用程序对象

asyncthreads的Python项目详细描述


AsyncThreads模块提供通用的线程设计模式和实用程序 用于异步和多线程编程。包括一根线 池和反应堆,它们结合在一起,创造了一个高度可靠的 并发事件处理系统。

安装

使用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中的examplestest目录。

要求

  • Python 2.7 or greater

开发工具

开发工具仅用于执行开发工作和运行 测验。

  • mercurial
  • py.test
  • pychecker

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

推荐PyPI第三方库


热门话题
Java例外。Lang.Stringindexoutofboundsexception索引超出范围(0)   java Spring引导Freemarker从2.2.0升级失败   重构Java反模式名称?包含对象的对象包含。。。等   用java处理JDBC可能出现的死锁的最佳方法   java无法访问主线程上的数据库,因为它可能会在很长一段时间内锁定UI   java如何将固定大小的画布包装在边框窗格中的滚动窗格居中?   java解析xsd文件后得到空结果   在html页面中表示XML文件的java   socketjava对象流   sql Java越界异常数据库   JavaJBoss7.1.1不会在Mavericks上启动   Twincat ADS事件驱动读取在一段时间后停止工作(Java)   java MyBatis使用生成的ID插入所有   Mojave上缺少MacOS Java控制面板   JavaGuice:如果多次注入相同的依赖项,是否注入了该依赖项的相同实例?