rename the project from aiogreen to aioeventlet
This commit is contained in:
2
Makefile
2
Makefile
@@ -5,7 +5,7 @@ test:
|
|||||||
doc:
|
doc:
|
||||||
make -C doc html
|
make -C doc html
|
||||||
clean:
|
clean:
|
||||||
rm -rf build dist aiogreen.egg-info .tox
|
rm -rf build dist aioeventlet.egg-info .tox
|
||||||
find -name "*.pyc" -delete
|
find -name "*.pyc" -delete
|
||||||
find -name "__pycache__" -exec rm -rf {} \;
|
find -name "__pycache__" -exec rm -rf {} \;
|
||||||
make -C doc clean
|
make -C doc clean
|
||||||
|
|||||||
25
README
25
README
@@ -1,17 +1,18 @@
|
|||||||
aiogreen implements the asyncio API (PEP 3156) on top of eventlet. It makes
|
aioeventlet implements the asyncio API (PEP 3156) on top of eventlet. It makes
|
||||||
possible to write asyncio code in a project currently written for eventlet.
|
possible to write asyncio code in a project currently written for eventlet.
|
||||||
|
|
||||||
aiogreen allows to use greenthreads in asyncio coroutines, and to use asyncio
|
aioeventlet allows to use greenthreads in asyncio coroutines, and to use
|
||||||
coroutines, tasks and futures in greenthreads: see ``link_future()`` and
|
asyncio coroutines, tasks and futures in greenthreads: see ``link_future()``
|
||||||
``wrap_greenthread()`` functions.
|
and ``wrap_greenthread()`` functions.
|
||||||
|
|
||||||
The main visible difference between aiogreen and trollius is the behaviour of
|
The main visible difference between aioeventlet and trollius is the behaviour
|
||||||
``run_forever()``: ``run_forever()`` blocks with trollius, whereas it runs in a
|
of ``run_forever()``: ``run_forever()`` blocks with trollius, whereas it runs
|
||||||
greenthread with aiogreen. It means that aiogreen event loop can run in an
|
in a greenthread with aioeventlet. It means that aioeventlet event loop can run
|
||||||
greenthread while the Python main thread runs other greenthreads in parallel.
|
in an greenthread while the Python main thread runs other greenthreads in
|
||||||
|
parallel.
|
||||||
|
|
||||||
* `aiogreen documentation <http://aiogreen.readthedocs.org/>`_
|
* `aioeventlet documentation <http://aioeventlet.readthedocs.org/>`_
|
||||||
* `aiogreen project in the Python Cheeseshop (PyPI)
|
* `aioeventlet project in the Python Cheeseshop (PyPI)
|
||||||
<https://pypi.python.org/pypi/aiogreen>`_
|
<https://pypi.python.org/pypi/aioeventlet>`_
|
||||||
* `aiogreen project at Bitbucket <https://bitbucket.org/haypo/aiogreen>`_
|
* `aioeventlet project at Bitbucket <https://bitbucket.org/haypo/aioeventlet>`_
|
||||||
* Copyright/license: Open source, Apache 2.0. Enjoy!
|
* Copyright/license: Open source, Apache 2.0. Enjoy!
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import sys
|
|||||||
socket = eventlet.patcher.original('socket')
|
socket = eventlet.patcher.original('socket')
|
||||||
threading = eventlet.patcher.original('threading')
|
threading = eventlet.patcher.original('threading')
|
||||||
|
|
||||||
logger = logging.getLogger('aiogreen')
|
logger = logging.getLogger('aioeventlet')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -315,12 +315,12 @@ def yield_future(future, loop=None):
|
|||||||
Return the result or raise the exception of the future.
|
Return the result or raise the exception of the future.
|
||||||
|
|
||||||
The function must not be called from the greenthread
|
The function must not be called from the greenthread
|
||||||
of the aiogreen event loop.
|
of the aioeventlet event loop.
|
||||||
"""
|
"""
|
||||||
future = asyncio.async(future, loop=loop)
|
future = asyncio.async(future, loop=loop)
|
||||||
if future._loop._greenthread == eventlet.getcurrent():
|
if future._loop._greenthread == eventlet.getcurrent():
|
||||||
raise RuntimeError("yield_future() must not be called from "
|
raise RuntimeError("yield_future() must not be called from "
|
||||||
"the greenthread of the aiogreen event loop")
|
"the greenthread of the aioeventlet event loop")
|
||||||
|
|
||||||
event = eventlet.event.Event()
|
event = eventlet.event.Event()
|
||||||
def done(fut):
|
def done(fut):
|
||||||
@@ -85,17 +85,17 @@ qthelp:
|
|||||||
@echo
|
@echo
|
||||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aiogreen.qhcp"
|
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/aioeventlet.qhcp"
|
||||||
@echo "To view the help file:"
|
@echo "To view the help file:"
|
||||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aiogreen.qhc"
|
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/aioeventlet.qhc"
|
||||||
|
|
||||||
devhelp:
|
devhelp:
|
||||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||||
@echo
|
@echo
|
||||||
@echo "Build finished."
|
@echo "Build finished."
|
||||||
@echo "To view the help file:"
|
@echo "To view the help file:"
|
||||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/aiogreen"
|
@echo "# mkdir -p $$HOME/.local/share/devhelp/aioeventlet"
|
||||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aiogreen"
|
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/aioeventlet"
|
||||||
@echo "# devhelp"
|
@echo "# devhelp"
|
||||||
|
|
||||||
epub:
|
epub:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Changelog
|
|||||||
Version 0.4
|
Version 0.4
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
* Rename the project from ``aiogreen`` to ``aioeventlet``
|
||||||
* Rename the ``link_future()`` function to :func:`yield_future`
|
* Rename the ``link_future()`` function to :func:`yield_future`
|
||||||
|
|
||||||
2014-10-23: version 0.3
|
2014-10-23: version 0.3
|
||||||
|
|||||||
14
doc/conf.py
14
doc/conf.py
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# aiogreen documentation build configuration file, created by
|
# aioeventlet documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Fri Nov 21 04:29:49 2014.
|
# sphinx-quickstart on Fri Nov 21 04:29:49 2014.
|
||||||
#
|
#
|
||||||
# This file is execfile()d with the current directory set to its
|
# This file is execfile()d with the current directory set to its
|
||||||
@@ -43,7 +43,7 @@ source_suffix = '.rst'
|
|||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'aiogreen'
|
project = u'aioeventlet'
|
||||||
copyright = u'2014, Victor Stinner'
|
copyright = u'2014, Victor Stinner'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
@@ -176,7 +176,7 @@ html_static_path = ['_static']
|
|||||||
#html_file_suffix = None
|
#html_file_suffix = None
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'aiogreendoc'
|
htmlhelp_basename = 'aioeventletdoc'
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output ---------------------------------------------
|
# -- Options for LaTeX output ---------------------------------------------
|
||||||
@@ -196,7 +196,7 @@ latex_elements = {
|
|||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index', 'aiogreen.tex', u'aiogreen Documentation',
|
('index', 'aioeventlet.tex', u'aioeventlet Documentation',
|
||||||
u'Victor Stinner', 'manual'),
|
u'Victor Stinner', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ latex_documents = [
|
|||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'aiogreen', u'aiogreen Documentation',
|
('index', 'aioeventlet', u'aioeventlet Documentation',
|
||||||
[u'Victor Stinner'], 1)
|
[u'Victor Stinner'], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -240,8 +240,8 @@ man_pages = [
|
|||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'aiogreen', u'aiogreen Documentation',
|
('index', 'aioeventlet', u'aioeventlet Documentation',
|
||||||
u'Victor Stinner', 'aiogreen', 'One line description of project.',
|
u'Victor Stinner', 'aioeventlet', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
aiogreen
|
aioeventlet
|
||||||
========
|
===========
|
||||||
|
|
||||||
.. image:: poplar_hawk-moth.jpg
|
.. image:: poplar_hawk-moth.jpg
|
||||||
:alt: Poplar Hawk-moth (Laothoe populi), photo taken in France
|
:alt: Poplar Hawk-moth (Laothoe populi), photo taken in France
|
||||||
:align: right
|
:align: right
|
||||||
:target: https://www.flickr.com/photos/haypo/7181768969/in/set-72157629731066236
|
:target: https://www.flickr.com/photos/haypo/7181768969/in/set-72157629731066236
|
||||||
|
|
||||||
aiogreen implements the asyncio API (`PEP 3156
|
aioeventlet implements the asyncio API (`PEP 3156
|
||||||
<http://www.python.org/dev/peps/pep-3156/>`_) on top of eventlet. It makes
|
<http://www.python.org/dev/peps/pep-3156/>`_) on top of eventlet. It makes
|
||||||
possible to write asyncio code in a project currently written for eventlet.
|
possible to write asyncio code in a project currently written for eventlet.
|
||||||
|
|
||||||
aiogreen allows to use greenthreads in asyncio coroutines, and to use asyncio
|
aioeventlet allows to use greenthreads in asyncio coroutines, and to use asyncio
|
||||||
coroutines, tasks and futures in greenthreads: see :func:`yield_future` and
|
coroutines, tasks and futures in greenthreads: see :func:`yield_future` and
|
||||||
:func:`wrap_greenthread` functions.
|
:func:`wrap_greenthread` functions.
|
||||||
|
|
||||||
The main visible difference between aiogreen and trollius is the behaviour of
|
The main visible difference between aioeventlet and trollius is the behaviour of
|
||||||
``run_forever()``: ``run_forever()`` blocks with trollius, whereas it runs in a
|
``run_forever()``: ``run_forever()`` blocks with trollius, whereas it runs in a
|
||||||
greenthread with aiogreen. It means that aiogreen event loop can run in an
|
greenthread with aioeventlet. It means that aioeventlet event loop can run in an
|
||||||
greenthread while the Python main thread runs other greenthreads in parallel.
|
greenthread while the Python main thread runs other greenthreads in parallel.
|
||||||
|
|
||||||
* `aiogreen documentation <http://aiogreen.readthedocs.org/>`_
|
* `aioeventlet documentation <http://aioeventlet.readthedocs.org/>`_
|
||||||
* `aiogreen project in the Python Cheeseshop (PyPI)
|
* `aioeventlet project in the Python Cheeseshop (PyPI)
|
||||||
<https://pypi.python.org/pypi/aiogreen>`_
|
<https://pypi.python.org/pypi/aioeventlet>`_
|
||||||
* `aiogreen project at Bitbucket <https://bitbucket.org/haypo/aiogreen>`_
|
* `aioeventlet project at Bitbucket <https://bitbucket.org/haypo/aioeventlet>`_
|
||||||
* Copyright/license: Open source, Apache 2.0. Enjoy!
|
* Copyright/license: Open source, Apache 2.0. Enjoy!
|
||||||
|
|
||||||
Table Of Contents
|
Table Of Contents
|
||||||
@@ -38,7 +38,7 @@ Table Of Contents
|
|||||||
Event loops
|
Event loops
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Projects used by aiogreen:
|
Projects used by aioeventlet:
|
||||||
|
|
||||||
* `asyncio documentation <http://docs.python.org/dev/library/asyncio.html>`_
|
* `asyncio documentation <http://docs.python.org/dev/library/asyncio.html>`_
|
||||||
* `trollius documentation <http://trollius.readthedocs.org/>`_
|
* `trollius documentation <http://trollius.readthedocs.org/>`_
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ if "%1" == "qthelp" (
|
|||||||
echo.
|
echo.
|
||||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\aiogreen.qhcp
|
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\aioeventlet.qhcp
|
||||||
echo.To view the help file:
|
echo.To view the help file:
|
||||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\aiogreen.ghc
|
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\aioeventlet.ghc
|
||||||
goto end
|
goto end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ Already done:
|
|||||||
* Write the trollius project: port asyncio to Python 2
|
* Write the trollius project: port asyncio to Python 2
|
||||||
* Stabilize trollius API
|
* Stabilize trollius API
|
||||||
* Add trollius dependency to OpenStack
|
* Add trollius dependency to OpenStack
|
||||||
* Write the aiogreen project to provide the asyncio API on top of eventlet
|
* Write the aioeventlet project to provide the asyncio API on top of eventlet
|
||||||
|
|
||||||
To do:
|
To do:
|
||||||
|
|
||||||
* Stabilize aiogreen API
|
* Stabilize aioeventlet API
|
||||||
* Add aiogreen dependency to OpenStack
|
* Add aioeventlet dependency to OpenStack
|
||||||
* Write an aiogreen executor for Oslo Messaging: rewrite greenio executor
|
* Write an aioeventlet executor for Oslo Messaging: rewrite greenio executor
|
||||||
to replace greenio with aiogreen
|
to replace greenio with aioeventlet
|
||||||
|
|
||||||
Second part (to do): rewrite code as trollius coroutines
|
Second part (to do): rewrite code as trollius coroutines
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
@@ -46,9 +46,9 @@ with a lot of legacy code, it has many drivers and the code base is large.
|
|||||||
To do:
|
To do:
|
||||||
|
|
||||||
* Ceilometer: add trollius dependency and set the trollius event loop policy to
|
* Ceilometer: add trollius dependency and set the trollius event loop policy to
|
||||||
aiogreen
|
aioeventlet
|
||||||
* Ceilometer: change Oslo Messaging executor from "eventlet" to "aiogreen"
|
* Ceilometer: change Oslo Messaging executor from "eventlet" to "aioeventlet"
|
||||||
* Redesign the service class of Oslo Incubator to support aiogreen and/or
|
* Redesign the service class of Oslo Incubator to support aioeventlet and/or
|
||||||
trollius. Currently, the class is designed for eventlet. The service class
|
trollius. Currently, the class is designed for eventlet. The service class
|
||||||
is instanciated before forking, which requires hacks on eventlet to update
|
is instanciated before forking, which requires hacks on eventlet to update
|
||||||
file descriptors.
|
file descriptors.
|
||||||
@@ -77,7 +77,7 @@ Questions:
|
|||||||
Last part (to do): drop eventlet
|
Last part (to do): drop eventlet
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Replace aiogreen event loop with trollius event loop, drop aiogreen and drop
|
Replace aioeventlet event loop with trollius event loop, drop aioeventlet and drop
|
||||||
eventlet at the end.
|
eventlet at the end.
|
||||||
|
|
||||||
This change will be done on applications one by one. This is no need to port
|
This change will be done on applications one by one. This is no need to port
|
||||||
@@ -90,7 +90,7 @@ To do:
|
|||||||
* Write a "trollius" executor for Oslo Messaging
|
* Write a "trollius" executor for Oslo Messaging
|
||||||
* Ceilometer: Add a blocking call to ``loop.run_forever()`` in the ``main()``
|
* Ceilometer: Add a blocking call to ``loop.run_forever()`` in the ``main()``
|
||||||
function
|
function
|
||||||
* Ceilometer: Replace "aiogreen" executor with "trollius" executor
|
* Ceilometer: Replace "aioeventlet" executor with "trollius" executor
|
||||||
* Ceilometer: Use the standard trollius event loop policy
|
* Ceilometer: Use the standard trollius event loop policy
|
||||||
* Ceilometer: drop the eventlet dependency
|
* Ceilometer: drop the eventlet dependency
|
||||||
|
|
||||||
@@ -110,13 +110,13 @@ Optimization, can be done later:
|
|||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Maybe the good one, aiogreen project:
|
Maybe the good one, aioeventlet project:
|
||||||
|
|
||||||
* Novembre 23, two patches posted to Oslo Messaging:
|
* Novembre 23, two patches posted to Oslo Messaging:
|
||||||
`Add a new aiogreen executor <https://review.openstack.org/#/c/136653/>`_
|
`Add a new aioeventlet executor <https://review.openstack.org/#/c/136653/>`_
|
||||||
and `Add an optional executor callback to dispatcher
|
and `Add an optional executor callback to dispatcher
|
||||||
<https://review.openstack.org/#/c/136652/>`_
|
<https://review.openstack.org/#/c/136652/>`_
|
||||||
* November 19, 2014: First release of the aiogreen project
|
* November 19, 2014: First release of the aioeventlet project
|
||||||
|
|
||||||
OpenStack Kilo Summit, November 3-7, 2014, at Paris:
|
OpenStack Kilo Summit, November 3-7, 2014, at Paris:
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ First try with a trollius executor for Oslo Messaging:
|
|||||||
* March 21, 2014: Patch `Replace ad-hoc coroutines with Trollius coroutines
|
* March 21, 2014: Patch `Replace ad-hoc coroutines with Trollius coroutines
|
||||||
<https://review.openstack.org/#/c/77925/>`_ proposed to Heat. Heat coroutines
|
<https://review.openstack.org/#/c/77925/>`_ proposed to Heat. Heat coroutines
|
||||||
are close to Trollius coroutines. Patch abandonned, need to be rewritten,
|
are close to Trollius coroutines. Patch abandonned, need to be rewritten,
|
||||||
maybe with aiogreen.
|
maybe with aioeventlet.
|
||||||
* February 20, 2014: The full specification of the blueprint was written:
|
* February 20, 2014: The full specification of the blueprint was written:
|
||||||
`Oslo/blueprints/asyncio
|
`Oslo/blueprints/asyncio
|
||||||
<https://wiki.openstack.org/wiki/Oslo/blueprints/asyncio>`_
|
<https://wiki.openstack.org/wiki/Oslo/blueprints/asyncio>`_
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ To do
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
* register signals in eventlet hub, only needed for pyevent hub?
|
* register signals in eventlet hub, only needed for pyevent hub?
|
||||||
* port greenio examples to aiogreen
|
* port greenio examples to aioeventlet
|
||||||
* write unit tests for, and maybe also examples for:
|
* write unit tests for, and maybe also examples for:
|
||||||
|
|
||||||
- TCP server
|
- TCP server
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Use aiogreen with trollius
|
Use aioeventlet with trollius
|
||||||
--------------------------
|
-----------------------------
|
||||||
|
|
||||||
aiogreen can be used with trollius, coroutines written with ``yield
|
aioeventlet can be used with trollius, coroutines written with ``yield
|
||||||
From(...)``. Using aiogreen with trollius is a good start to port project
|
From(...)``. Using aioeventlet with trollius is a good start to port project
|
||||||
written for eventlet to trollius.
|
written for eventlet to trollius.
|
||||||
|
|
||||||
To use aiogreen with trollius, set the event loop policy before using an event
|
To use aioeventlet with trollius, set the event loop policy before using an event
|
||||||
loop, example::
|
loop, example::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import trollius
|
import trollius
|
||||||
|
|
||||||
trollius.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
trollius.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
# ....
|
# ....
|
||||||
|
|
||||||
Hello World::
|
Hello World::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import trollius as asyncio
|
import trollius as asyncio
|
||||||
|
|
||||||
def hello_world():
|
def hello_world():
|
||||||
print("Hello World")
|
print("Hello World")
|
||||||
loop.stop()
|
loop.stop()
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.call_soon(hello_world)
|
loop.call_soon(hello_world)
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
@@ -36,39 +36,39 @@ Hello World::
|
|||||||
`Trollius documentation <http://trollius.readthedocs.org/>`_.
|
`Trollius documentation <http://trollius.readthedocs.org/>`_.
|
||||||
|
|
||||||
|
|
||||||
Use aiogreen with asyncio
|
Use aioeventlet with asyncio
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
aiogreen can be used with asyncio, coroutines written with ``yield from ...``.
|
aioeventlet can be used with asyncio, coroutines written with ``yield from ...``.
|
||||||
To use aiogreen with asyncio, set the event loop policy before using an event
|
To use aioeventlet with asyncio, set the event loop policy before using an event
|
||||||
loop. Example::
|
loop. Example::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
# ....
|
# ....
|
||||||
|
|
||||||
Setting the event loop policy should be enough to examples of the asyncio
|
Setting the event loop policy should be enough to examples of the asyncio
|
||||||
documentation with the aiogreen event loop.
|
documentation with the aioeventlet event loop.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
Since aiogreen relies on eventlet, eventlet port to Python 3 is not complete
|
Since aioeventlet relies on eventlet, eventlet port to Python 3 is not complete
|
||||||
and asyncio requires Python 3.3 or newer: using aiogreen with asyncio is not
|
and asyncio requires Python 3.3 or newer: using aioeventlet with asyncio is not
|
||||||
recommended yet. *Using aiogreen with trollius should be preferred right
|
recommended yet. *Using aioeventlet with trollius should be preferred right
|
||||||
now*. See the :ref:`status of the eventlet port to Python 3
|
now*. See the :ref:`status of the eventlet port to Python 3
|
||||||
<eventlet-py3>`.
|
<eventlet-py3>`.
|
||||||
|
|
||||||
Hello World::
|
Hello World::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
def hello_world():
|
def hello_world():
|
||||||
print("Hello World")
|
print("Hello World")
|
||||||
loop.stop()
|
loop.stop()
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.call_soon(hello_world)
|
loop.call_soon(hello_world)
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
@@ -92,7 +92,7 @@ and threading.Queue to pass data between threads.
|
|||||||
Use ``threading = eventlet.patcher.original('threading')`` to get the original
|
Use ``threading = eventlet.patcher.original('threading')`` to get the original
|
||||||
threading instead of ``import threading``.
|
threading instead of ``import threading``.
|
||||||
|
|
||||||
It is not possible to run two aiogreen event loops in the same thread.
|
It is not possible to run two aioeventlet event loops in the same thread.
|
||||||
|
|
||||||
|
|
||||||
Debug mode
|
Debug mode
|
||||||
@@ -121,10 +121,10 @@ event loop, but it enables less debug checks.
|
|||||||
API
|
API
|
||||||
===
|
===
|
||||||
|
|
||||||
aiogreen specific functions:
|
aioeventlet specific functions:
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
aiogreen API is not considered as stable yet.
|
aioeventlet API is not considered as stable yet.
|
||||||
|
|
||||||
yield_future
|
yield_future
|
||||||
------------
|
------------
|
||||||
@@ -135,19 +135,19 @@ yield_future
|
|||||||
|
|
||||||
Return the result or raise the exception of the future.
|
Return the result or raise the exception of the future.
|
||||||
|
|
||||||
The function must not be called from the greenthread of the aiogreen event
|
The function must not be called from the greenthread of the aioeventlet event
|
||||||
loop.
|
loop.
|
||||||
|
|
||||||
.. versionchanged:: 0.3
|
.. versionchanged:: 0.3
|
||||||
|
|
||||||
Coroutine objects are also accepted. Added the *loop* parameter.
|
Coroutine objects are also accepted. Added the *loop* parameter.
|
||||||
An exception is raised if it is called from the greenthread of the
|
An exception is raised if it is called from the greenthread of the
|
||||||
aiogreen event loop.
|
aioeventlet event loop.
|
||||||
|
|
||||||
Example of greenthread waiting for a trollius task. The ``progress()``
|
Example of greenthread waiting for a trollius task. The ``progress()``
|
||||||
callback is called regulary to see that the event loop in not blocked::
|
callback is called regulary to see that the event loop in not blocked::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import eventlet
|
import eventlet
|
||||||
import trollius as asyncio
|
import trollius as asyncio
|
||||||
from trollius import From, Return
|
from trollius import From, Return
|
||||||
@@ -166,12 +166,12 @@ yield_future
|
|||||||
|
|
||||||
task = asyncio.async(coro_slow_sum(1, 2))
|
task = asyncio.async(coro_slow_sum(1, 2))
|
||||||
|
|
||||||
value = aiogreen.yield_future(task)
|
value = aioeventlet.yield_future(task)
|
||||||
print("1 + 2 = %s" % value)
|
print("1 + 2 = %s" % value)
|
||||||
|
|
||||||
loop.stop()
|
loop.stop()
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
eventlet.spawn(green_sum)
|
eventlet.spawn(green_sum)
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
@@ -208,7 +208,7 @@ wrap_greenthread
|
|||||||
Example of trollius coroutine waiting for a greenthread. The ``progress()``
|
Example of trollius coroutine waiting for a greenthread. The ``progress()``
|
||||||
callback is called regulary to see that the event loop in not blocked::
|
callback is called regulary to see that the event loop in not blocked::
|
||||||
|
|
||||||
import aiogreen
|
import aioeventlet
|
||||||
import eventlet
|
import eventlet
|
||||||
import trollius as asyncio
|
import trollius as asyncio
|
||||||
from trollius import From, Return
|
from trollius import From, Return
|
||||||
@@ -226,12 +226,12 @@ wrap_greenthread
|
|||||||
loop.call_soon(progress)
|
loop.call_soon(progress)
|
||||||
|
|
||||||
gt = eventlet.spawn(slow_sum, 1, 2)
|
gt = eventlet.spawn(slow_sum, 1, 2)
|
||||||
fut = aiogreen.wrap_greenthread(gt, loop=loop)
|
fut = aioeventlet.wrap_greenthread(gt, loop=loop)
|
||||||
|
|
||||||
result = yield From(fut)
|
result = yield From(fut)
|
||||||
print("1 + 2 = %s" % result)
|
print("1 + 2 = %s" % result)
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(aiogreen.EventLoopPolicy())
|
asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(coro_sum())
|
loop.run_until_complete(coro_sum())
|
||||||
loop.close()
|
loop.close()
|
||||||
@@ -247,15 +247,15 @@ wrap_greenthread
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
Install aiogreen with pip
|
Install aioeventlet with pip
|
||||||
-------------------------
|
----------------------------
|
||||||
|
|
||||||
Type::
|
Type::
|
||||||
|
|
||||||
pip install aiogreen
|
pip install aioeventlet
|
||||||
|
|
||||||
Install aiogreen on Windows with pip
|
Install aioeventlet on Windows with pip
|
||||||
------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Procedure for Python 2.7:
|
Procedure for Python 2.7:
|
||||||
|
|
||||||
@@ -265,13 +265,13 @@ Procedure for Python 2.7:
|
|||||||
|
|
||||||
\Python27\python.exe get-pip.py
|
\Python27\python.exe get-pip.py
|
||||||
|
|
||||||
* Install aiogreen with pip::
|
* Install aioeventlet with pip::
|
||||||
|
|
||||||
\Python27\python.exe -m pip install aiogreen
|
\Python27\python.exe -m pip install aioeventlet
|
||||||
|
|
||||||
* pip also installs dependencies: ``eventlet`` and ``trollius``
|
* pip also installs dependencies: ``eventlet`` and ``trollius``
|
||||||
|
|
||||||
Manual installation of aiogreen
|
Manual installation of aioeventlet
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -42,7 +42,7 @@ with open("README") as fp:
|
|||||||
long_description = fp.read()
|
long_description = fp.read()
|
||||||
|
|
||||||
install_options = {
|
install_options = {
|
||||||
"name": "aiogreen",
|
"name": "aioeventlet",
|
||||||
"version": "0.4",
|
"version": "0.4",
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache License 2.0",
|
||||||
"author": 'Victor Stinner',
|
"author": 'Victor Stinner',
|
||||||
@@ -50,7 +50,7 @@ install_options = {
|
|||||||
|
|
||||||
"description": "asyncio event loop scheduling callbacks in eventlet.",
|
"description": "asyncio event loop scheduling callbacks in eventlet.",
|
||||||
"long_description": long_description,
|
"long_description": long_description,
|
||||||
"url": "http://aiogreen.readthedocs.org/",
|
"url": "http://aioeventlet.readthedocs.org/",
|
||||||
|
|
||||||
"classifiers": [
|
"classifiers": [
|
||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
@@ -58,7 +58,7 @@ install_options = {
|
|||||||
"License :: OSI Approved :: Apache Software License",
|
"License :: OSI Approved :: Apache Software License",
|
||||||
],
|
],
|
||||||
|
|
||||||
"py_modules": ["aiogreen"],
|
"py_modules": ["aioeventlet"],
|
||||||
#"test_suite": "runtests.runtests",
|
#"test_suite": "runtests.runtests",
|
||||||
}
|
}
|
||||||
if SETUPTOOLS:
|
if SETUPTOOLS:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import aiogreen
|
import aioeventlet
|
||||||
try:
|
try:
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -15,7 +15,7 @@ except ImportError:
|
|||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class TestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
policy = aiogreen.EventLoopPolicy()
|
policy = aioeventlet.EventLoopPolicy()
|
||||||
asyncio.set_event_loop_policy(policy)
|
asyncio.set_event_loop_policy(policy)
|
||||||
self.addCleanup(asyncio.set_event_loop_policy, None)
|
self.addCleanup(asyncio.set_event_loop_policy, None)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from aiogreen import socketpair
|
from aioeventlet import socketpair
|
||||||
import eventlet
|
import eventlet
|
||||||
import tests
|
import tests
|
||||||
socket = eventlet.patcher.original('socket')
|
socket = eventlet.patcher.original('socket')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import aiogreen
|
import aioeventlet
|
||||||
import eventlet
|
import eventlet
|
||||||
import sys
|
import sys
|
||||||
import tests
|
import tests
|
||||||
@@ -24,16 +24,16 @@ try:
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
|
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
|
||||||
value = yield from aiogreen.wrap_greenthread(gt)
|
value = yield from aioeventlet.wrap_greenthread(gt)
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
|
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
|
||||||
value = yield from aiogreen.wrap_greenthread(gt)
|
value = yield from aioeventlet.wrap_greenthread(gt)
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_error)
|
gt = eventlet.spawn(eventlet_slow_error)
|
||||||
try:
|
try:
|
||||||
yield from aiogreen.wrap_greenthread(gt)
|
yield from aioeventlet.wrap_greenthread(gt)
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
result.append(str(exc))
|
result.append(str(exc))
|
||||||
|
|
||||||
@@ -60,16 +60,16 @@ except ImportError:
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
|
gt = eventlet.spawn(eventlet_slow_append, result, 1, 0.020)
|
||||||
value = yield From(aiogreen.wrap_greenthread(gt))
|
value = yield From(aioeventlet.wrap_greenthread(gt))
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
|
gt = eventlet.spawn(eventlet_slow_append, result, 2, 0.010)
|
||||||
value = yield From(aiogreen.wrap_greenthread(gt))
|
value = yield From(aioeventlet.wrap_greenthread(gt))
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
gt = eventlet.spawn(eventlet_slow_error)
|
gt = eventlet.spawn(eventlet_slow_error)
|
||||||
try:
|
try:
|
||||||
yield From(aiogreen.wrap_greenthread(gt))
|
yield From(aioeventlet.wrap_greenthread(gt))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
result.append(str(exc))
|
result.append(str(exc))
|
||||||
|
|
||||||
@@ -90,14 +90,14 @@ except ImportError:
|
|||||||
|
|
||||||
def greenthread_yield_future(result, loop):
|
def greenthread_yield_future(result, loop):
|
||||||
try:
|
try:
|
||||||
value = aiogreen.yield_future(coro_slow_append(result, 1, 0.020))
|
value = aioeventlet.yield_future(coro_slow_append(result, 1, 0.020))
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
value = aiogreen.yield_future(coro_slow_append(result, 2, 0.010))
|
value = aioeventlet.yield_future(coro_slow_append(result, 2, 0.010))
|
||||||
result.append(value)
|
result.append(value)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value = aiogreen.yield_future(coro_slow_error())
|
value = aioeventlet.yield_future(coro_slow_error())
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
result.append(str(exc))
|
result.append(str(exc))
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ class LinkFutureTests(tests.TestCase):
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
def func(fut):
|
def func(fut):
|
||||||
value = aiogreen.yield_future(coro_slow_append(result, 3))
|
value = aioeventlet.yield_future(coro_slow_append(result, 3))
|
||||||
result.append(value)
|
result.append(value)
|
||||||
self.loop.stop()
|
self.loop.stop()
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ class LinkFutureTests(tests.TestCase):
|
|||||||
|
|
||||||
def func(event, fut):
|
def func(event, fut):
|
||||||
event.send('link')
|
event.send('link')
|
||||||
value = aiogreen.yield_future(fut)
|
value = aioeventlet.yield_future(fut)
|
||||||
result.append(value)
|
result.append(value)
|
||||||
self.loop.stop()
|
self.loop.stop()
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ class LinkFutureTests(tests.TestCase):
|
|||||||
|
|
||||||
def func(fut):
|
def func(fut):
|
||||||
try:
|
try:
|
||||||
value = aiogreen.yield_future(fut)
|
value = aioeventlet.yield_future(fut)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
result.append('error')
|
result.append('error')
|
||||||
else:
|
else:
|
||||||
@@ -221,7 +221,7 @@ class LinkFutureTests(tests.TestCase):
|
|||||||
|
|
||||||
def test_yield_future_invalid_type(self):
|
def test_yield_future_invalid_type(self):
|
||||||
def func(obj):
|
def func(obj):
|
||||||
return aiogreen.yield_future(obj)
|
return aioeventlet.yield_future(obj)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def coro_func():
|
def coro_func():
|
||||||
@@ -243,7 +243,7 @@ class LinkFutureTests(tests.TestCase):
|
|||||||
|
|
||||||
def func(fut):
|
def func(fut):
|
||||||
try:
|
try:
|
||||||
value = aiogreen.yield_future(fut, loop=loop2)
|
value = aioeventlet.yield_future(fut, loop=loop2)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
result.append(str(exc))
|
result.append(str(exc))
|
||||||
else:
|
else:
|
||||||
@@ -265,7 +265,7 @@ class WrapGreenthreadTests(tests.TestCase):
|
|||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
gt = eventlet.spawn(func)
|
gt = eventlet.spawn(func)
|
||||||
fut = aiogreen.wrap_greenthread(gt)
|
fut = aioeventlet.wrap_greenthread(gt)
|
||||||
result = self.loop.run_until_complete(fut)
|
result = self.loop.run_until_complete(fut)
|
||||||
self.assertEqual(result, 'ok')
|
self.assertEqual(result, 'ok')
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ class WrapGreenthreadTests(tests.TestCase):
|
|||||||
# FIXME: the unit test must fail!?
|
# FIXME: the unit test must fail!?
|
||||||
with tests.mock.patch('traceback.print_exception') as print_exception:
|
with tests.mock.patch('traceback.print_exception') as print_exception:
|
||||||
gt = eventlet.spawn(func)
|
gt = eventlet.spawn(func)
|
||||||
fut = aiogreen.wrap_greenthread(gt)
|
fut = aioeventlet.wrap_greenthread(gt)
|
||||||
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
||||||
|
|
||||||
# the exception must not be logger by traceback: the caller must
|
# the exception must not be logger by traceback: the caller must
|
||||||
@@ -287,7 +287,7 @@ class WrapGreenthreadTests(tests.TestCase):
|
|||||||
|
|
||||||
def test_wrap_greenthread_running(self):
|
def test_wrap_greenthread_running(self):
|
||||||
def func():
|
def func():
|
||||||
return aiogreen.wrap_greenthread(gt)
|
return aioeventlet.wrap_greenthread(gt)
|
||||||
|
|
||||||
self.loop.set_debug(False)
|
self.loop.set_debug(False)
|
||||||
gt = eventlet.spawn(func)
|
gt = eventlet.spawn(func)
|
||||||
@@ -304,7 +304,7 @@ class WrapGreenthreadTests(tests.TestCase):
|
|||||||
|
|
||||||
msg = "wrap_greenthread: the greenthread already finished"
|
msg = "wrap_greenthread: the greenthread already finished"
|
||||||
self.assertRaisesRegexp(RuntimeError, msg,
|
self.assertRaisesRegexp(RuntimeError, msg,
|
||||||
aiogreen.wrap_greenthread, gt)
|
aioeventlet.wrap_greenthread, gt)
|
||||||
|
|
||||||
def test_coro_wrap_greenthread(self):
|
def test_coro_wrap_greenthread(self):
|
||||||
result = self.loop.run_until_complete(coro_wrap_greenthread())
|
result = self.loop.run_until_complete(coro_wrap_greenthread())
|
||||||
@@ -313,14 +313,14 @@ class WrapGreenthreadTests(tests.TestCase):
|
|||||||
def test_wrap_invalid_type(self):
|
def test_wrap_invalid_type(self):
|
||||||
def func():
|
def func():
|
||||||
pass
|
pass
|
||||||
self.assertRaises(TypeError, aiogreen.wrap_greenthread, func)
|
self.assertRaises(TypeError, aioeventlet.wrap_greenthread, func)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def coro_func():
|
def coro_func():
|
||||||
pass
|
pass
|
||||||
coro_obj = coro_func()
|
coro_obj = coro_func()
|
||||||
self.addCleanup(coro_obj.close)
|
self.addCleanup(coro_obj.close)
|
||||||
self.assertRaises(TypeError, aiogreen.wrap_greenthread, coro_obj)
|
self.assertRaises(TypeError, aioeventlet.wrap_greenthread, coro_obj)
|
||||||
|
|
||||||
|
|
||||||
class WrapGreenletTests(tests.TestCase):
|
class WrapGreenletTests(tests.TestCase):
|
||||||
@@ -330,7 +330,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
return "ok"
|
return "ok"
|
||||||
|
|
||||||
gt = eventlet.spawn_n(func)
|
gt = eventlet.spawn_n(func)
|
||||||
fut = aiogreen.wrap_greenthread(gt)
|
fut = aioeventlet.wrap_greenthread(gt)
|
||||||
result = self.loop.run_until_complete(fut)
|
result = self.loop.run_until_complete(fut)
|
||||||
self.assertEqual(result, "ok")
|
self.assertEqual(result, "ok")
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
raise ValueError(7)
|
raise ValueError(7)
|
||||||
|
|
||||||
gt = eventlet.spawn_n(func)
|
gt = eventlet.spawn_n(func)
|
||||||
fut = aiogreen.wrap_greenthread(gt)
|
fut = aioeventlet.wrap_greenthread(gt)
|
||||||
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
||||||
|
|
||||||
def test_wrap_greenlet_running(self):
|
def test_wrap_greenlet_running(self):
|
||||||
@@ -350,7 +350,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
def func():
|
def func():
|
||||||
try:
|
try:
|
||||||
gt = eventlet.getcurrent()
|
gt = eventlet.getcurrent()
|
||||||
fut = aiogreen.wrap_greenthread(gt)
|
fut = aioeventlet.wrap_greenthread(gt)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
event.send_exception(exc)
|
event.send_exception(exc)
|
||||||
else:
|
else:
|
||||||
@@ -368,7 +368,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
gt = eventlet.spawn_n(func)
|
gt = eventlet.spawn_n(func)
|
||||||
event.wait()
|
event.wait()
|
||||||
msg = "wrap_greenthread: the greenthread already finished"
|
msg = "wrap_greenthread: the greenthread already finished"
|
||||||
self.assertRaisesRegexp(RuntimeError, msg, aiogreen.wrap_greenthread, gt)
|
self.assertRaisesRegexp(RuntimeError, msg, aioeventlet.wrap_greenthread, gt)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import aiogreen
|
import aioeventlet
|
||||||
import greenlet
|
import greenlet
|
||||||
import tests
|
import tests
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
return value * 3
|
return value * 3
|
||||||
|
|
||||||
gl = greenlet.greenlet(func)
|
gl = greenlet.greenlet(func)
|
||||||
fut = aiogreen.wrap_greenthread(gl)
|
fut = aioeventlet.wrap_greenthread(gl)
|
||||||
gl.switch(5)
|
gl.switch(5)
|
||||||
result = self.loop.run_until_complete(fut)
|
result = self.loop.run_until_complete(fut)
|
||||||
self.assertEqual(result, 15)
|
self.assertEqual(result, 15)
|
||||||
@@ -19,7 +19,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
raise ValueError(7)
|
raise ValueError(7)
|
||||||
|
|
||||||
gl = greenlet.greenlet(func)
|
gl = greenlet.greenlet(func)
|
||||||
fut = aiogreen.wrap_greenthread(gl)
|
fut = aioeventlet.wrap_greenthread(gl)
|
||||||
gl.switch()
|
gl.switch()
|
||||||
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
self.assertRaises(ValueError, self.loop.run_until_complete, fut)
|
||||||
|
|
||||||
@@ -27,12 +27,12 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
gl = greenlet.greenlet()
|
gl = greenlet.greenlet()
|
||||||
msg = "wrap_greenthread: the run attribute of the greenlet is not set"
|
msg = "wrap_greenthread: the run attribute of the greenlet is not set"
|
||||||
self.assertRaisesRegexp(RuntimeError, msg,
|
self.assertRaisesRegexp(RuntimeError, msg,
|
||||||
aiogreen.wrap_greenthread, gl)
|
aioeventlet.wrap_greenthread, gl)
|
||||||
|
|
||||||
def test_wrap_greenlet_running(self):
|
def test_wrap_greenlet_running(self):
|
||||||
def func(value):
|
def func(value):
|
||||||
gl = greenlet.getcurrent()
|
gl = greenlet.getcurrent()
|
||||||
return aiogreen.wrap_greenthread(gl)
|
return aioeventlet.wrap_greenthread(gl)
|
||||||
|
|
||||||
gl = greenlet.greenlet(func)
|
gl = greenlet.greenlet(func)
|
||||||
msg = "wrap_greenthread: the greenthread is running"
|
msg = "wrap_greenthread: the greenthread is running"
|
||||||
@@ -45,7 +45,7 @@ class WrapGreenletTests(tests.TestCase):
|
|||||||
gl = greenlet.greenlet(func)
|
gl = greenlet.greenlet(func)
|
||||||
gl.switch(5)
|
gl.switch(5)
|
||||||
msg = "wrap_greenthread: the greenthread already finished"
|
msg = "wrap_greenthread: the greenthread already finished"
|
||||||
self.assertRaisesRegexp(RuntimeError, msg, aiogreen.wrap_greenthread, gl)
|
self.assertRaisesRegexp(RuntimeError, msg, aioeventlet.wrap_greenthread, gl)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user