txaio


Nametxaio JSON
Version 23.1.1 PyPI version JSON
download
home_pagehttps://github.com/crossbario/txaio
SummaryCompatibility API between asyncio/Twisted/Trollius
upload_time2023-01-15 14:11:27
maintainer
docs_urlNone
authortypedef int GmbH
requires_python>=3.7
licenseMIT License
keywords asyncio twisted trollius coroutine
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            txaio
=====

| |Version| |Build| |Deploy| |Coverage| |Docs|

--------------

**txaio** is a helper library for writing code that runs unmodified on
both `Twisted <https://twistedmatrix.com/>`_ and `asyncio <https://docs.python.org/3/library/asyncio.html>`_ / `Trollius <http://trollius.readthedocs.org/en/latest/index.html>`_.

This is like `six <http://pythonhosted.org/six/>`_, but for wrapping
over differences between Twisted and asyncio so one can write code
that runs unmodified on both (aka *source code compatibility*). In
other words: your *users* can choose if they want asyncio **or** Twisted
as a dependency.

Note that, with this approach, user code **runs under the native event
loop of either Twisted or asyncio**. This is different from attaching
either one's event loop to the other using some event loop adapter.


Platform support
----------------

**txaio** runs on CPython 3.6+ and PyPy 3, on top of *Twisted* or *asyncio*. Specifically, **txaio** is tested on the following platforms:

* CPython 3.6 and 3.9 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib)
* PyPy 3.6 an 3.7 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib)

> Note: txaio up to version 18.8.1 also supported Python 2.7 and Python 3.4. Beginning with release v20.1.1, txaio only supports Python 3.5+. Beginning with release v20.12.1, txaio only supports Python 3.6+.


How it works
------------

Instead of directly importing, instantiating and using ``Deferred``
(for Twisted) or ``Future`` (for asyncio) objects, **txaio** provides
helper-functions to do that for you, as well as associated things like
adding callbacks or errbacks.

This obviously changes the style of your code, but then you can choose
at runtime (or import time) which underlying event-loop to use. This
means you can write **one** code-base that can run on Twisted *or*
asyncio (without a Twisted dependency) as you or your users see fit.

Code like the following can then run on *either* system:

.. sourcecode:: python

    import txaio
    txaio.use_twisted()  # or .use_asyncio()

    f0 = txaio.create_future()
    f1 = txaio.as_future(some_func, 1, 2, key='word')
    txaio.add_callbacks(f0, callback, errback)
    txaio.add_callbacks(f1, callback, errback)
    # ...
    txaio.resolve(f0, "value")
    txaio.reject(f1, RuntimeError("it failed"))

Please refer to the `documentation <https://txaio.readthedocs.io/en/latest/>`_ for description and usage of the library features.


.. |Version| image:: https://img.shields.io/pypi/v/txaio.svg
   :target: https://pypi.python.org/pypi/txaio
   :alt: Version

.. |Build| image:: https://github.com/crossbario/txaio/workflows/main/badge.svg
   :target: https://github.com/crossbario/txaio/actions?query=workflow%3Amain
   :alt: Build Workflow

.. |Deploy| image:: https://github.com/crossbario/txaio/workflows/deploy/badge.svg
   :target: https://github.com/crossbario/txaio/actions?query=workflow%3Adeploy
   :alt: Deploy Workflow

.. |Coverage| image:: https://codecov.io/github/crossbario/txaio/coverage.svg?branch=master
   :target: https://codecov.io/github/crossbario/txaio
   :alt: Coverage

.. |Docs| image:: https://readthedocs.org/projects/txaio/badge/?version=latest
   :target: https://txaio.readthedocs.io/en/latest/
   :alt: Docs

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/crossbario/txaio",
    "name": "txaio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "asyncio twisted trollius coroutine",
    "author": "typedef int GmbH",
    "author_email": "autobahnws@googlegroups.com",
    "download_url": "https://files.pythonhosted.org/packages/51/91/bc9fd5aa84703f874dea27313b11fde505d343f3ef3ad702bddbe20bfd6e/txaio-23.1.1.tar.gz",
    "platform": "Any",
    "description": "txaio\n=====\n\n| |Version| |Build| |Deploy| |Coverage| |Docs|\n\n--------------\n\n**txaio** is a helper library for writing code that runs unmodified on\nboth `Twisted <https://twistedmatrix.com/>`_ and `asyncio <https://docs.python.org/3/library/asyncio.html>`_ / `Trollius <http://trollius.readthedocs.org/en/latest/index.html>`_.\n\nThis is like `six <http://pythonhosted.org/six/>`_, but for wrapping\nover differences between Twisted and asyncio so one can write code\nthat runs unmodified on both (aka *source code compatibility*). In\nother words: your *users* can choose if they want asyncio **or** Twisted\nas a dependency.\n\nNote that, with this approach, user code **runs under the native event\nloop of either Twisted or asyncio**. This is different from attaching\neither one's event loop to the other using some event loop adapter.\n\n\nPlatform support\n----------------\n\n**txaio** runs on CPython 3.6+ and PyPy 3, on top of *Twisted* or *asyncio*. Specifically, **txaio** is tested on the following platforms:\n\n* CPython 3.6 and 3.9 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib)\n* PyPy 3.6 an 3.7 on Twisted 18.7, 19.10, trunk and on asyncio (stdlib)\n\n> Note: txaio up to version 18.8.1 also supported Python 2.7 and Python 3.4. Beginning with release v20.1.1, txaio only supports Python 3.5+. Beginning with release v20.12.1, txaio only supports Python 3.6+.\n\n\nHow it works\n------------\n\nInstead of directly importing, instantiating and using ``Deferred``\n(for Twisted) or ``Future`` (for asyncio) objects, **txaio** provides\nhelper-functions to do that for you, as well as associated things like\nadding callbacks or errbacks.\n\nThis obviously changes the style of your code, but then you can choose\nat runtime (or import time) which underlying event-loop to use. This\nmeans you can write **one** code-base that can run on Twisted *or*\nasyncio (without a Twisted dependency) as you or your users see fit.\n\nCode like the following can then run on *either* system:\n\n.. sourcecode:: python\n\n    import txaio\n    txaio.use_twisted()  # or .use_asyncio()\n\n    f0 = txaio.create_future()\n    f1 = txaio.as_future(some_func, 1, 2, key='word')\n    txaio.add_callbacks(f0, callback, errback)\n    txaio.add_callbacks(f1, callback, errback)\n    # ...\n    txaio.resolve(f0, \"value\")\n    txaio.reject(f1, RuntimeError(\"it failed\"))\n\nPlease refer to the `documentation <https://txaio.readthedocs.io/en/latest/>`_ for description and usage of the library features.\n\n\n.. |Version| image:: https://img.shields.io/pypi/v/txaio.svg\n   :target: https://pypi.python.org/pypi/txaio\n   :alt: Version\n\n.. |Build| image:: https://github.com/crossbario/txaio/workflows/main/badge.svg\n   :target: https://github.com/crossbario/txaio/actions?query=workflow%3Amain\n   :alt: Build Workflow\n\n.. |Deploy| image:: https://github.com/crossbario/txaio/workflows/deploy/badge.svg\n   :target: https://github.com/crossbario/txaio/actions?query=workflow%3Adeploy\n   :alt: Deploy Workflow\n\n.. |Coverage| image:: https://codecov.io/github/crossbario/txaio/coverage.svg?branch=master\n   :target: https://codecov.io/github/crossbario/txaio\n   :alt: Coverage\n\n.. |Docs| image:: https://readthedocs.org/projects/txaio/badge/?version=latest\n   :target: https://txaio.readthedocs.io/en/latest/\n   :alt: Docs\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Compatibility API between asyncio/Twisted/Trollius",
    "version": "23.1.1",
    "split_keywords": [
        "asyncio",
        "twisted",
        "trollius",
        "coroutine"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d6ca53cc9a97c2da76d9cd83c03f377468599a28f2d4ad9fc71c3b99640e71e",
                "md5": "d9cfb2ca5cfe2888b3b4c47be9b770ad",
                "sha256": "aaea42f8aad50e0ecfb976130ada140797e9dcb85fad2cf72b0f37f8cefcb490"
            },
            "downloads": -1,
            "filename": "txaio-23.1.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d9cfb2ca5cfe2888b3b4c47be9b770ad",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 30512,
            "upload_time": "2023-01-15T14:11:24",
            "upload_time_iso_8601": "2023-01-15T14:11:24.999459Z",
            "url": "https://files.pythonhosted.org/packages/7d/6c/a53cc9a97c2da76d9cd83c03f377468599a28f2d4ad9fc71c3b99640e71e/txaio-23.1.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5191bc9fd5aa84703f874dea27313b11fde505d343f3ef3ad702bddbe20bfd6e",
                "md5": "297409f2dff8e71bad24467374aa8775",
                "sha256": "f9a9216e976e5e3246dfd112ad7ad55ca915606b60b84a757ac769bd404ff704"
            },
            "downloads": -1,
            "filename": "txaio-23.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "297409f2dff8e71bad24467374aa8775",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 53704,
            "upload_time": "2023-01-15T14:11:27",
            "upload_time_iso_8601": "2023-01-15T14:11:27.475463Z",
            "url": "https://files.pythonhosted.org/packages/51/91/bc9fd5aa84703f874dea27313b11fde505d343f3ef3ad702bddbe20bfd6e/txaio-23.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-15 14:11:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "crossbario",
    "github_project": "txaio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "txaio"
}
        
Elapsed time: 0.07152s