python eventlet库 之一

空闲之余,开始翻译一下eventlet库

目录在http://eventlet.net/doc/

协程产生

1.eventlet.spawn(func*args**kw)

这个是发起协程(greenthread)来调用func指向的函数,并且有返回或错误

2.eventlet.spawn_n(func*args**kw)

这个是发起协程(greenthread)来调用func指向的函数,但无返回或错误

3.eventlet.spawn_after(secondsfunc*args**kw)

是spawn的延迟版本,在seconds后调用func。期间可以对其返回值调用GreenThread.cancel()


协程控制

eventlet. sleep ( seconds=0 )

挂起当前协程,允许其他的得到执行

class  eventlet. GreenPool

并发控制池。让程序执行时,只占用一定的内存,或者限定某种连接的数量,或者对未知的数据输入保持稳定性能的功效。

class  eventlet. GreenPile

能输入任务,并产生输出的迭代器

class  eventlet. Queue

执行单元之间的基本数据交互的数据结构。用来在协程间来提供一系列功能。

class  eventlet. Timeout

This class is a way to add timeouts to anything. It raises exception in the current greenthread after timeout seconds. When exception is omitted or None, the Timeout instance itself is raised.

给某物添加时限。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值