Pass in an action, function, method or coroutine.
传入一个动作,函数,方法或协程。
It's just a way to communicate with the coroutine scheduler without using global (or thread-local) variables.
它只是一种方法与协同调度通信而不需要使用全局(或局部)变量。
The thing to notice about this wrapper is that each generator/coroutine yields a tuple that contains its intended branch destination.
关于这个包装器要注意的一点是,每个生成器/协同程序都会生成一个包含它的预期分支目标的元组。
And since not all generators are written to be used in a coroutine-based control flow, you need to avoid accidentally using a generator incorrectly.
而且,由于不是所有的发电机都写在一个基于协程控制流程中使用,你需要避免不慎使用发电机不正确。
You may be wondering why the difference between what an async-based coroutine and a generator-based coroutine will accept in their respective pausing expressions?
你可能会奇怪,为什么一个什么样的区别异步基于协同程序和基于发电机协同程序将在各自的暂停表情接受吗?
Since generators inherently implement the API for coroutines then it would be easy to accidentally use a generator when you actually expected to be using a coroutine.
由于发电机本身实施协程API的话,那就很容易意外地使用发电机当你真正希望使用一个协同程序。
There are of course efficient green thread and coroutine implementations which allow you to write asynchronous code in a synchronous looking way – Eventlet for example.
绿色线程固然有效率得多,调度得更快,而且还有一个好处是,写异步的代码跟写同步的样子差不多。
There are of course efficient green thread and coroutine implementations which allow you to write asynchronous code in a synchronous looking way – Eventlet for example.
绿色线程固然有效率得多,调度得更快,而且还有一个好处是,写异步的代码跟写同步的样子差不多。
应用推荐