eventlet.event.Event
来源:互联网 发布:c语言if语句例题 编辑:程序博客网 时间:2024/06/09 14:13
http://eventlet.net/doc/modules/event.html
功能:用来在协程之间通信
class eventlet.event.
Event
An abstraction where an arbitrary number of coroutines(任意数量的协同程序) can wait for one event from another.
Events are similar to a Queue that can only hold one item, but differ in two important ways:
- calling
send()
never unschedules the current greenthread send()
can only be called once; create a new event to send again.
They are good for communicating results between coroutines, and are the basis for how GreenThread.wait()
is implemented(他们有助于在协同程序之间传达结果,并且是实现GreenThread.wait()的基础).
ready
()Return true if the
wait()
call will return immediately. Used to avoid waiting for things that might take a while to time out. For example, you can put a bunch of events into a list, and then visit them all repeatedly, callingready()
until one returnsTrue
, and then you canwait()
on that one.例如,您可以将一堆事件放入列表中,然后重复访问它们,调用ready()直到返回True,然后可以wait()在那一个。
send
(result=None, exc=None)Makes arrangements for the waiters to be woken with the result and then returns immediately to the parent.
It is an error to call
send()
multiple times on the same event.Use
reset()
betweensend()
s to reuse an event object.
Same as
send()
, but sends an exception to waiters.The arguments to send_exception are the same as the arguments to
raise
. If a single exception object(异常对象) is passed in, it will be re-raised whenwait()
is called, generating a new stacktrace. send_exception的参数与引用的参数相同。 如果传入一个异常对象,调用wait()时会重新生成一个异常对象,生成一个新的堆栈跟踪If it’s important to preserve(保护) the entire original stack trace, you must pass in the entire
sys.exc_info()
tuple.Note that doing so stores a traceback object directly on the Event object, which may cause reference cycles. See the
sys.exc_info()
documentation.
send_exception
(*args)
wait
()Wait until another coroutine calls
send()
. Returns the value the other coroutine passed tosend()
.Returns immediately if the event has already occurred.
- eventlet.event.Event
- Event
- Event
- Event
- Event
- Event
- event
- event
- event
- Event
- event
- Event
- Event
- event
- event()
- event
- Event
- Event
- C#基础-050 结构
- 关于JAVA中的static方法、并发问题以及JAVA运行时内存模型
- Linux后端开发
- uva 156 Ananagrams STL
- Xcode报错:embedded dylibs/frameworks are only supported on iOS 8.0 and later
- eventlet.event.Event
- JAVA设计模式---适配器模式
- HTML5 canvas绘图
- java日期格式化及获取相关总结
- Kruskal
- openwrt添加新平台支持
- codeforces 214A System of Equations
- 用qt写出来的一个网络爬虫
- C# 中字符串string和字节数组byte[]之间的转换