Trololio: Trollius and asyncio compatibility library¶
Trololio allows your program to have a soft dependency on trollius in Python versions where asyncio (aka Tulip) is part of the standard library.
Trololio provides a compatibility layer for Trollius and asyncio, it addresses the differences listed in Trollius and Tulip:
- Allows the use of Trollius’ syntax with asyncio.
- Provides missing objects and aliases for the others.
- Synchronizes debug environment variables.
Indices and tables¶
Converting Code¶
If your code was written for asyncio, convert it to use Trollius.
Change your trollius imports:
- from trollius import coroutine, From, Return + from trololio import coroutine, From, Return - import trollius + from trololio import asyncio
If you used the second import style:
- trollius.* + [trololio.]asyncio.*
note: | Make sure you use coroutine(), From() and Return from trololio and not asyncio. Otherwise an ImportError will be raised when running with asyncio (Tulip). |
---|
Module contents¶
ASYNCIO and TROLLIUS are always of opposite value.
Trollius objects¶
The following objects are aliases for the trollius ones, or defined by trololio.
- trololio.coroutine()¶
trollius.coroutine or equivalent allowing yield From(x).
- trololio.From()¶
trollius.From or equivalent.
- exception trololio.Return¶
trollius.Return or equivalent.
- trololio.BACKPORT_SSL_ERRORS¶
trollius.BACKPORT_SSL_ERRORS or False.
- trololio.BACKPORT_SSL_CONTEXT¶
trollius.BACKPORT_SSL_CONTEXT or False.
Standard library objects¶
The following objects are aliases for the trollius ones, or aliases for the standard library ones.
OSError and socket.error exceptions¶
- exception trololio.BlockingIOError¶
trollius.BlockingIOError or BlockingIOError.
- exception trololio.BrokenPipeError¶
trollius.BrokenPipeError or BrokenPipeError.
- exception trololio.ChildProcessError¶
trollius.ChildProcessError or ChildProcessError.
- exception trololio.ConnectionAbortedError¶
trollius.ConnectionAbortedError or ConnectionAbortedError.
- exception trololio.ConnectionRefusedError¶
trollius.ConnectionRefusedError or ConnectionRefusedError.
- exception trololio.ConnectionResetError¶
trollius.ConnectionResetError or ConnectionResetError.
- exception trololio.FileNotFoundError¶
trollius.FileNotFoundError or FileNotFoundError.
- exception trololio.InterruptedError¶
trollius.InterruptedError or InterruptedError.
- exception trololio.PermissionError¶
trollius.PermissionError or PermissionError.
SSLError¶
- exception trololio.SSLEOFError¶
trollius.SSLEOFError or ssl.SSLEOFError.
- exception trololio.SSLWantReadError¶
trollius.SSLWantReadError or ssl.SSLWantReadError.
- exception trololio.SSLWantWriteError¶
trollius.SSLWantWriteError or ssl.SSLWantWriteError.
SSLContext¶
- class trololio.SSLContext¶
trollius.SSLContext or ssl.SSLContext.
asyncio submodule¶
Trololio provides the asyncio submodule. It is either trollius, the first choice, or asyncio (Tulip), the fallback.
note: | If neither module was found, an ImportError is raised. |
---|