txaio.tx
========

.. py:module:: txaio.tx


Attributes
----------

.. autoapisummary::

   txaio.tx._categories
   txaio.tx._default_api
   txaio.tx._log_level
   txaio.tx._loggers
   txaio.tx._observer
   txaio.tx._started_logging
   txaio.tx._unspecified
   txaio.tx.add_callbacks
   txaio.tx.as_future
   txaio.tx.call_later
   txaio.tx.cancel
   txaio.tx.config
   txaio.tx.create_failure
   txaio.tx.create_future
   txaio.tx.create_future_error
   txaio.tx.create_future_success
   txaio.tx.failure_format_traceback
   txaio.tx.failure_message
   txaio.tx.failure_traceback
   txaio.tx.gather
   txaio.tx.is_called
   txaio.tx.is_future
   txaio.tx.make_batched_timer
   txaio.tx.perf_counter_ns
   txaio.tx.reject
   txaio.tx.resolve
   txaio.tx.sleep
   txaio.tx.time_ns
   txaio.tx.using_asyncio
   txaio.tx.using_twisted


Classes
-------

.. autoapisummary::

   txaio.tx.Logger
   txaio.tx._LogObserver
   txaio.tx._TxApi


Functions
---------

.. autoapisummary::

   txaio.tx._no_op
   txaio.tx.add_log_categories
   txaio.tx.get_global_log_level
   txaio.tx.make_logger
   txaio.tx.set_global_log_level
   txaio.tx.start_logging
   txaio.tx.with_config


Module Contents
---------------

.. py:class:: Logger(level=None, logger=None, namespace=None, observer=None)

   Bases: :py:obj:`object`


   .. py:method:: __get__(oself, type=None)


   .. py:method:: _failure(format=None, *args, **kw)


   .. py:method:: _log(level, *args, **kwargs)


   .. py:attribute:: _log_level_set_explicitly
      :value: False



   .. py:attribute:: _logger


   .. py:method:: _set_log_level(level)


   .. py:method:: _trace(*args, **kw)


   .. py:method:: emit(level, *args, **kwargs)


   .. py:method:: set_log_level(level, keep=True)

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



.. py:class:: _LogObserver(out)

   Bases: :py:obj:`object`


   Internal helper.

   An observer which formats events to a given file.


   .. py:method:: __call__(event)


   .. py:method:: _acceptable_level(level)


   .. py:attribute:: _encode
      :value: True



   .. py:attribute:: _file


   .. py:attribute:: _levels
      :value: None



   .. py:attribute:: to_tx


.. py:class:: _TxApi(config)

   Bases: :py:obj:`object`


   .. py:attribute:: _config


   .. py:method:: _get_loop()

      internal helper



   .. py:method:: add_callbacks(future, callback, errback)

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



   .. py:method:: as_future(fun, *args, **kwargs)


   .. py:method:: call_later(delay, fun, *args, **kwargs)


   .. py:method:: cancel(future, msg=None)


   .. py:method:: create_failure(exception=None)

      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



   .. py:method:: create_future(result=_unspecified, error=_unspecified, canceller=None)


   .. py:method:: create_future_error(error=None)


   .. py:method:: create_future_success(result)


   .. py:method:: failure_format_traceback(fail)

      :param fail: must be an IFailedFuture
      returns a string



   .. py:method:: failure_message(fail)

      :param fail: must be an IFailedFuture
      returns a unicode error-message



   .. py:method:: failure_traceback(fail)

      :param fail: must be an IFailedFuture
      returns a traceback instance



   .. py:method:: gather(futures, consume_exceptions=True)


   .. py:method:: is_called(future)


   .. py:method:: is_future(obj)


   .. py:method:: make_batched_timer(bucket_seconds, chunk_size=100)

      Creates and returns an object implementing
      :class:`txaio.IBatchedTimer`.

      :param 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".

      :param chunk_size: when "doing" the callbacks in a particular
          bucket, this controls how many we do at once before yielding to
          the reactor.



   .. py:method:: reject(future, error=None)


   .. py:method:: resolve(future, result=None)


   .. py:method:: sleep(delay)

      Inline sleep for use in co-routines.

      :param delay: Time to sleep in seconds.
      :type delay: float



.. py:data:: _categories

.. py:data:: _default_api

.. py:data:: _log_level
   :value: 'info'


.. py:data:: _loggers

.. py:function:: _no_op(*args, **kwargs)

.. py:data:: _observer
   :value: None


.. py:data:: _started_logging
   :value: False


.. py:data:: _unspecified

.. py:data:: add_callbacks

.. py:function:: add_log_categories(categories)

.. py:data:: as_future

.. py:data:: call_later

.. py:data:: cancel

.. py:data:: config

.. py:data:: create_failure

.. py:data:: create_future

.. py:data:: create_future_error

.. py:data:: create_future_success

.. py:data:: failure_format_traceback

.. py:data:: failure_message

.. py:data:: failure_traceback

.. py:data:: gather

.. py:function:: get_global_log_level()

.. py:data:: is_called

.. py:data:: is_future

.. py:data:: make_batched_timer

.. py:function:: make_logger(level=None, logger=_Logger, observer=None)

.. py:data:: perf_counter_ns

.. py:data:: reject

.. py:data:: resolve

.. py:function:: set_global_log_level(level)

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


.. py:data:: sleep

.. py:function:: start_logging(out=_stdout, level='info')

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


.. py:data:: time_ns

.. py:data:: using_asyncio
   :value: False


.. py:data:: using_twisted
   :value: True


.. py:function:: with_config(loop=None)

