空闲之余,开始翻译一下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(seconds, func, *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.
-
给某物添加时限。