txaio.aio¶
Attributes¶
Classes¶
This provides an object with any features from Twisted's Failure |
Functions¶
|
|
|
Set the global log level on all loggers instantiated by txaio. |
|
Begin logging. |
|
Module Contents¶
- class FailedFuture(type_, value, traceback)[source]¶
Bases:
txaio.interfaces.IFailedFutureThis provides an object with any features from Twisted’s Failure that we might need in Autobahn classes that use FutureMixin.
We need to encapsulate information from exceptions so that errbacks still have access to the traceback (in case they want to print it out) outside of “except” blocks.
- start_logging(out=_stdout, level='info')[source]¶
Begin logging.
- Parameters:
out – if provided, a file-like object to log to. By default, this is stdout.
level – the maximum log-level to emit (a string)
- with_config(loop=None)[source]¶
- Returns:
an instance of the txaio API with the given configuration. This won’t affect anything using the ‘gloabl’ config nor other instances created using this function.
If you need to customize txaio configuration separately (e.g. to use multiple event-loops in asyncio), you can take code like this:
import txaio
class FunTimes(object):
- def something_async(self):
return txaio.call_later(1, lambda: ‘some result’)
and instead do this:
import txaio
- class FunTimes(object):
txaio = txaio
- def something_async(self):
# this will run in the local/new event loop created in the constructor return self.txaio.call_later(1, lambda: ‘some result’)
fun0 = FunTimes() fun1 = FunTimes() fun1.txaio = txaio.with_config(loop=asyncio.new_event_loop())
So fun1 will run its futures on the newly-created event loop, while fun0 will work just as it did before this with_config method was introduced (after 2.6.2).