以绿带为基础的龙卷风协同活动
greenado的Python项目详细描述
格林纳多图片:https://travis-ci.org/virtuald/greenado.png?branch=master
:目标:https://travis ci.org/virtuald/greenado
:alt:测试状态
…图片::https://coveralls.io/repos/virtuald/greenado/badge.png
:目标:https://coveralls.io/r/virtuald/greenado
:alt:测试覆盖率状态
。图片::https://readthedocs.org/projects/greenado/badge/?version=latest
:目标:https://readthedocs.org/projects/greenado/?badge=latest
:alt:documentation
greenado是一个实用程序库,为
tornado提供基于greenlet的协同程序。在Tornado中,协程允许您执行异步操作
,而不使用回调,在
函数中提供伪同步流。
从下到上都要有感染力。换句话说,为了让它们真正有用,
协程的调用方应该向它们"屈服",这要求它们是一个
协程。反过来,他们的呼叫者需要"屈服",等等。
使用decorator时,可以使用:func:`greenado.gyield()<;greenado.concurrent.gyield>;`
伪同步等待异步事件发生。这减少了大型代码库中的复杂性,因为您只需要在调用树的最顶端使用decorator,而无需其他地方。
iElements
==
使用PIP安装最简单:
…代码块::bash
$pip install greenado
tornado 4+
我只在linux&osx上测试过greenado,但我认为它可以在tornado和greenlet支持的平台上正常工作。.
示例用法
==
这个:
…代码块::python
operation()
提高gen.return(retval)
@gen.coroutine
def main_function():
retval=yield call_long_operation()
代码块::python
retval=greenado.gyield(long_operation())
retval
retval=do_long_operation()
retval
@greenado.g例程
def main_function():
retval=call_long_operation()
dd_future<;tornado.ioloop.ioloop.add_future>;`on,否则您可能会有吞咽异常的风险。
为什么我不能使用yield关键字?
----------
好吧,实际上,如果您使用另一个装饰器,您仍然可以!退房
这个例子:
…代码块::python
@greenado.generator
def do_long_operation():
retval=yield long_operation()
retval
def call_long_operation():
retval=do_long_operation()
retval
@greenado.groutine
def main_function():
retval=call_long_operation()
执行任何特殊的
调用do_long_操作函数,而不是确保
:func:`@greenado.groutine<;greenado.concurrent.groutine>;`位于调用堆栈的某个位置。
testing
=
代码块::python
@gen_test
def test_something(self):
生成的东西()
产生新的变化
====
1。分叉此存储库
2。创建功能分支(`git checkout-b my new feature`)
3。测试您的更改(`tests/run_tests.sh`)
4。提交更改(`git commit-am'add some feature`)
5.推到分支(`git push origin my new feature`)
6。创建新的拉取请求
credit
=
greenado类似于https://github.com/mopub/greenlet tornado
和https://github.com/gawen/tornalet,并受其启发,但不要求您像使用tornado web处理程序一样使用它。
authors
=
dustin spicuzza(dustin@virtualroadside.com)
:目标:https://travis ci.org/virtuald/greenado
:alt:测试状态
…图片::https://coveralls.io/repos/virtuald/greenado/badge.png
:目标:https://coveralls.io/r/virtuald/greenado
:alt:测试覆盖率状态
。图片::https://readthedocs.org/projects/greenado/badge/?version=latest
:目标:https://readthedocs.org/projects/greenado/?badge=latest
:alt:documentation
greenado是一个实用程序库,为
tornado提供基于greenlet的协同程序。在Tornado中,协程允许您执行异步操作
,而不使用回调,在
函数中提供伪同步流。
从下到上都要有感染力。换句话说,为了让它们真正有用,
协程的调用方应该向它们"屈服",这要求它们是一个
协程。反过来,他们的呼叫者需要"屈服",等等。
使用decorator时,可以使用:func:`greenado.gyield()<;greenado.concurrent.gyield>;`
伪同步等待异步事件发生。这减少了大型代码库中的复杂性,因为您只需要在调用树的最顶端使用decorator,而无需其他地方。
iElements
==
使用PIP安装最简单:
…代码块::bash
$pip install greenado
我只在linux&osx上测试过greenado,但我认为它可以在tornado和greenlet支持的平台上正常工作。.
示例用法
==
这个:
…代码块::python
operation()
提高gen.return(retval)
@gen.coroutine
def main_function():
retval=yield call_long_operation()
代码块::python
retval
retval
@greenado.g例程
def main_function():
retval=call_long_operation()
dd_future<;tornado.ioloop.ioloop.add_future>;`on,否则您可能会有吞咽异常的风险。
为什么我不能使用yield关键字?
----------
好吧,实际上,如果您使用另一个装饰器,您仍然可以!退房
这个例子:
…代码块::python
@greenado.generator
def do_long_operation():
retval=yield long_operation()
retval
def call_long_operation():
retval=do_long_operation()
retval
@greenado.groutine
def main_function():
retval=call_long_operation()
执行任何特殊的
调用do_long_操作函数,而不是确保
:func:`@greenado.groutine<;greenado.concurrent.groutine>;`位于调用堆栈的某个位置。
testing
=
代码块::python
@gen_test
def test_something(self):
生成的东西()
产生新的变化
====
1。分叉此存储库
2。创建功能分支(`git checkout-b my new feature`)
3。测试您的更改(`tests/run_tests.sh`)
4。提交更改(`git commit-am'add some feature`)
5.推到分支(`git push origin my new feature`)
6。创建新的拉取请求
credit
=
greenado类似于https://github.com/mopub/greenlet tornado
和https://github.com/gawen/tornalet,并受其启发,但不要求您像使用tornado web处理程序一样使用它。
authors
=
dustin spicuzza(dustin@virtualroadside.com)