diff options
Diffstat (limited to 'doc/using.rst')
-rw-r--r-- | doc/using.rst | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/doc/using.rst b/doc/using.rst index 0676268..a87da56 100644 --- a/doc/using.rst +++ b/doc/using.rst @@ -1,26 +1,26 @@ Usage ===== -Use aioeventlet with trollius ------------------------------ - -aioeventlet can be used with trollius, coroutines written with ``yield -From(...)``. Using aioeventlet with trollius is a good start to port project -written for eventlet to trollius. +Use aioeventlet with asyncio +---------------------------- -To use aioeventlet with trollius, set the event loop policy before using an event -loop, example:: +aioeventlet can be used with asyncio, coroutines written with ``yield from ...``. +To use aioeventlet with asyncio, set the event loop policy before using an event +loop. Example:: import aioeventlet - import trollius + import asyncio - trollius.set_event_loop_policy(aioeventlet.EventLoopPolicy()) + asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy()) # .... +Setting the event loop policy should be enough to examples of the asyncio +documentation with the aioeventlet event loop. + Hello World:: import aioeventlet - import trollius as asyncio + import asyncio def hello_world(): print("Hello World") @@ -33,36 +33,35 @@ Hello World:: loop.close() .. seealso:: - `Trollius documentation <http://trollius.readthedocs.org/>`_. + The `asyncio documentation + <https://docs.python.org/dev/library/asyncio.html>`_. -Use aioeventlet with asyncio ----------------------------- +Use aioeventlet with trollius +----------------------------- -aioeventlet can be used with asyncio, coroutines written with ``yield from ...``. -To use aioeventlet with asyncio, set the event loop policy before using an event -loop. Example:: +.. warning:: + The `trollius project is now deprecated + <http://trollius.readthedocs.org/deprecated.html>`_. It's now recommended to + use aioeventlet with asyncio. - import aioeventlet - import asyncio +aioeventlet can be used with trollius, coroutines written with ``yield +From(...)``. Using aioeventlet with trollius is a good start to port project +written for eventlet to trollius. - asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy()) - # .... +To use aioeventlet with trollius, set the event loop policy before using an event +loop, example:: -Setting the event loop policy should be enough to examples of the asyncio -documentation with the aioeventlet event loop. + import aioeventlet + import trollius -.. warning:: - Since aioeventlet relies on eventlet, eventlet port to Python 3 is not complete - and asyncio requires Python 3.3 or newer: using aioeventlet with asyncio is not - recommended yet. *Using aioeventlet with trollius should be preferred right - now*. See the :ref:`status of the eventlet port to Python 3 - <eventlet-py3>`. + trollius.set_event_loop_policy(aioeventlet.EventLoopPolicy()) + # .... Hello World:: import aioeventlet - import asyncio + import trollius as asyncio def hello_world(): print("Hello World") @@ -75,8 +74,7 @@ Hello World:: loop.close() .. seealso:: - The `asyncio documentation - <https://docs.python.org/dev/library/asyncio.html>`_. + `Trollius documentation <http://trollius.readthedocs.org/>`_. Threads |