txaio.tx

Attributes

Classes

Logger

_LogObserver

Internal helper.

_TxApi

Functions

_no_op(*args, **kwargs)

add_log_categories(categories)

get_global_log_level()

make_logger([level, logger, observer])

set_global_log_level(level)

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

start_logging([out, level])

Start logging to the file-like object in out. By default, this

with_config([loop])

Module Contents

class Logger(level=None, logger=None, namespace=None, observer=None)[source]

Bases: object

__get__(oself, type=None)[source]
_failure(format=None, *args, **kw)[source]
_log(level, *args, **kwargs)[source]
_log_level_set_explicitly = False[source]
_logger[source]
_set_log_level(level)[source]
_trace(*args, **kw)[source]
emit(level, *args, **kwargs)[source]
set_log_level(level, keep=True)[source]

Set the log level. If keep is True, then it will not change along with global log changes.

class _LogObserver(out)[source]

Bases: object

Internal helper.

An observer which formats events to a given file.

__call__(event)[source]
_acceptable_level(level)[source]
_encode = True[source]
_file[source]
_levels = None[source]
to_tx[source]
class _TxApi(config)[source]

Bases: object

_config[source]
_get_loop()[source]

internal helper

add_callbacks(future, callback, errback)[source]

callback or errback may be None, but at least one must be non-None.

as_future(fun, *args, **kwargs)[source]
call_later(delay, fun, *args, **kwargs)[source]
cancel(future, msg=None)[source]
create_failure(exception=None)[source]

Create a Failure instance.

if exception is None (the default), we MUST be inside an “except” block. This encapsulates the exception into an object that implements IFailedFuture

create_future(result=_unspecified, error=_unspecified, canceller=None)[source]
create_future_error(error=None)[source]
create_future_success(result)[source]
failure_format_traceback(fail)[source]
Parameters:

fail – must be an IFailedFuture

returns a string

failure_message(fail)[source]
Parameters:

fail – must be an IFailedFuture

returns a unicode error-message

failure_traceback(fail)[source]
Parameters:

fail – must be an IFailedFuture

returns a traceback instance

gather(futures, consume_exceptions=True)[source]
is_called(future)[source]
is_future(obj)[source]
make_batched_timer(bucket_seconds, chunk_size=100)[source]

Creates and returns an object implementing txaio.IBatchedTimer.

Parameters:
  • bucket_seconds – the number of seconds in each bucket. That is, a value of 5 means that any timeout within a 5 second window will be in the same bucket, and get notified at the same time. This is only accurate to “milliseconds”.

  • chunk_size – when “doing” the callbacks in a particular bucket, this controls how many we do at once before yielding to the reactor.

reject(future, error=None)[source]
resolve(future, result=None)[source]
sleep(delay)[source]

Inline sleep for use in co-routines.

Parameters:

delay (float) – Time to sleep in seconds.

_categories[source]
_default_api[source]
_log_level = 'info'[source]
_loggers[source]
_no_op(*args, **kwargs)[source]
_observer = None[source]
_started_logging = False[source]
_unspecified[source]
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(level=None, logger=_Logger, observer=None)[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]
start_logging(out=_stdout, level='info')[source]

Start logging to the file-like object in out. By default, this is stdout.

time_ns[source]
using_asyncio = False[source]
using_twisted = True[source]
with_config(loop=None)[source]