txaio.aio

Attributes

Classes

AsyncGeneratorType

FailedFuture

This provides an object with any features from Twisted's Failure

Functions

add_log_categories(categories)

get_global_log_level()

make_logger()

set_global_log_level(level)

Set the global log level on all loggers instantiated by txaio.

start_logging([out, level])

Begin logging.

with_config([loop])

Module Contents

class AsyncGeneratorType[source]
class FailedFuture(type_, value, traceback)[source]

Bases: txaio.interfaces.IFailedFuture

This 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.

property value[source]

An actual Exception instance. Same as the second item returned from sys.exc_info()

add_callbacks[source]
add_log_categories(categories)[source]
as_future[source]
call_later[source]
cancel[source]
config[source]
create_failure[source]
create_future[source]
create_future_error[source]
create_future_success[source]
failure_format_traceback[source]
failure_message[source]
failure_traceback[source]
gather[source]
get_global_log_level()[source]
is_called[source]
is_future[source]
make_batched_timer[source]
make_logger()[source]
perf_counter_ns[source]
reject[source]
resolve[source]
set_global_log_level(level)[source]

Set the global log level on all loggers instantiated by txaio.

sleep[source]
sleep[source]
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)

time_ns[source]
using_asyncio = True[source]
using_twisted = False[source]
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).