diff options
| author | Victor Stinner <vstinner@redhat.com> | 2015-07-09 02:39:43 +0200 |
|---|---|---|
| committer | Victor Stinner <vstinner@redhat.com> | 2015-07-09 02:39:43 +0200 |
| commit | fe673cc69295a2a082f9840c85bfd3cbe303e117 (patch) | |
| tree | 4e73fe6f762243c16a8dede6e246ac88b76bbd4c | |
| parent | 6f52fbfaacae0322a9c3303f15ae44444c4b1e13 (diff) | |
| download | trollius-git-fe673cc69295a2a082f9840c85bfd3cbe303e117.tar.gz | |
replace Tulip with asyncio
| -rw-r--r-- | AUTHORS | 4 | ||||
| -rw-r--r-- | doc/asyncio.rst | 36 | ||||
| -rw-r--r-- | doc/index.rst | 5 | ||||
| -rw-r--r-- | trollius/coroutines.py | 2 |
4 files changed, 23 insertions, 24 deletions
@@ -9,6 +9,6 @@ The photo of Trollis flower was taken by Imartin6 and distributed under the CC BY-SA 3.0 license. It comes from: http://commons.wikimedia.org/wiki/File:Trollius_altaicus.jpg -Trollius is a port of the Tulip project on Python 2, see also authors of the -Tulip project (AUTHORS file of the Tulip project). +Trollius is a port of the asyncio project on Python 2, see also authors of the +asyncio project (AUTHORS file). diff --git a/doc/asyncio.rst b/doc/asyncio.rst index 5866d62..011a9a8 100644 --- a/doc/asyncio.rst +++ b/doc/asyncio.rst @@ -1,17 +1,17 @@ -++++++++++++++++++ -Trollius and Tulip -++++++++++++++++++ +++++++++++++++++++++ +Trollius and asyncio +++++++++++++++++++++ -Differences between Trollius and Tulip -====================================== +Differences between Trollius and asyncio +======================================== Syntax of coroutines -------------------- -The major difference between Trollius and Tulip is the syntax of coroutines: +The major difference between Trollius and asyncio is the syntax of coroutines: ================== ====================== -Tulip Trollius +asyncio Trollius ================== ====================== ``yield from ...`` ``yield From(...)`` ``yield from []`` ``yield From(None)`` @@ -129,41 +129,41 @@ Other differences ``BaseEventLoop.run_in_executor()`` uses a synchronous executor instead of a pool of threads. It blocks until the function returns. For example, DNS resolutions are blocking in this case. -* Trollius has more symbols than Tulip for compatibility with Python older than - 3.3: +* Trollius has more symbols than asyncio for compatibility with Python older + than 3.3: - ``From``: part of ``yield From(...)`` syntax - ``Return``: part of ``raise Return(...)`` syntax -Write code working on Trollius and Tulip -======================================== +Write code working on Trollius and asyncio +========================================== -Trollius and Tulip are different, especially for coroutines (``yield +Trollius and asyncio are different, especially for coroutines (``yield From(...)`` vs ``yield from ...``). To use asyncio or Trollius on Python 2 and Python 3, add the following code at the top of your file:: try: - # Use builtin asyncio on Python 3.4+, or Tulip on Python 3.3 + # Use builtin asyncio on Python 3.4+, or asyncio on Python 3.3 import asyncio except ImportError: # Use Trollius on Python <= 3.2 import trollius as asyncio It is possible to write code working on both projects using only callbacks. -This option is used by the following projects which work on Trollius and Tulip: +This option is used by the following projects which work on Trollius and asyncio: * `AutobahnPython <https://github.com/tavendo/AutobahnPython>`_: WebSocket & - WAMP for Python, it works on Trollius (Python 2.6 and 2.7), Tulip (Python + WAMP for Python, it works on Trollius (Python 2.6 and 2.7), asyncio (Python 3.3) and Python 3.4 (asyncio), and also on Twisted. * `Pulsar <http://pythonhosted.org/pulsar/>`_: Event driven concurrent framework for Python. With pulsar you can write asynchronous servers performing one or several activities in different threads and/or processes. Trollius 0.3 requires Pulsar 0.8.2 or later. Pulsar uses the ``asyncio`` module if available, or import ``trollius``. -* `Tornado <http://www.tornadoweb.org/>`_ supports Tulip and Trollius since +* `Tornado <http://www.tornadoweb.org/>`_ supports asyncio and Trollius since Tornado 3.2: `tornado.platform.asyncio — Bridge between asyncio and Tornado <http://tornado.readthedocs.org/en/latest/asyncio.html>`_. It tries to import asyncio or fallback on importing trollius. @@ -171,10 +171,10 @@ This option is used by the following projects which work on Trollius and Tulip: Another option is to provide functions returning ``Future`` objects, so the caller can decide to use callback using ``fut.add_done_callback(callback)`` or to use coroutines (``yield From(fut)`` for Trollius, or ``yield from fut`` for -Tulip). This option is used by the `aiodns <https://github.com/saghul/aiodns>`_ +asyncio). This option is used by the `aiodns <https://github.com/saghul/aiodns>`_ project for example. -Since Trollius 0.4, it's possible to use Tulip and Trollius coroutines in the +Since Trollius 0.4, it's possible to use asyncio and Trollius coroutines in the same process. The only limit is that the event loop must be a Trollius event loop. diff --git a/doc/index.rst b/doc/index.rst index 8625093..317f924 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -33,7 +33,7 @@ Here is a more detailed list of the package contents: * an interface for passing work off to a threadpool, for times when you absolutely, positively have to use a library that makes blocking I/O calls. -Trollius is a portage of the `Tulip project <http://code.google.com/p/tulip/>`_ +Trollius is a portage of the `asyncio project <https://github.com/python/asyncio>`_ (``asyncio`` module, `PEP 3156 <http://legacy.python.org/dev/peps/pep-3156/>`_) on Python 2. Trollius works on Python 2.6-3.5. It has been tested on Windows, Linux, Mac OS X, FreeBSD and OpenIndiana. @@ -50,8 +50,7 @@ Linux, Mac OS X, FreeBSD and OpenIndiana. * IRC: ``#asyncio`` channel on the `Freenode network <https://freenode.net/>`_ * Copyright/license: Open source, Apache 2.0. Enjoy! -See also the `Tulip project <http://code.google.com/p/tulip/>`_ (asyncio module -for Python 3.3). +See also the `asyncio project at Github <https://github.com/python/asyncio>`_. Table Of Contents diff --git a/trollius/coroutines.py b/trollius/coroutines.py index 45c2fe2..8bd0b7e 100644 --- a/trollius/coroutines.py +++ b/trollius/coroutines.py @@ -371,7 +371,7 @@ if events.asyncio is not None: if hasattr(events.asyncio, 'coroutines'): _COROUTINE_TYPES += (events.asyncio.coroutines.CoroWrapper,) else: - # old Tulip/Python versions + # old asyncio/Python versions _COROUTINE_TYPES += (events.asyncio.tasks.CoroWrapper,) def iscoroutine(obj): |
