autobahn.twisted.component


Module Contents

Classes

Component

A component establishes a transport and attached a session

Functions

run(components[, log_level, stop_at_close])

High-level API to run a series of components.

class autobahn.twisted.component.Component(main=None, transports=None, config=None, realm='realm1', extra=None, authentication=None, session_factory=None, is_fatal=None)[source]

Bases: autobahn.wamp.component.Component

A component establishes a transport and attached a session to a realm using the transport for communication.

The transports a component tries to use can be configured, as well as the auto-reconnect strategy.

log
session_factory

The factory of the session we will instantiate.

_is_ssl_error(e)[source]

Internal helper.

This is so we can just return False if we didn’t import any TLS/SSL libraries. Otherwise, returns True if this is an OpenSSL.SSL.Error

_check_native_endpoint(endpoint)[source]
_connect_transport(reactor, transport, session_factory, done)[source]

Create and connect a WAMP-over-XXX transport.

Parameters

done – is a Deferred/Future from the parent which we should signal upon error if it is not done yet (XXX maybe an “on_error” callable instead?)

start(reactor=None)[source]

This starts the Component, which means it will start connecting (and re-connecting) to its configured transports. A Component runs until it is “done”, which means one of: - There was a “main” function defined, and it completed successfully; - Something called .leave() on our session, and we left successfully; - .stop() was called, and completed successfully; - none of our transports were able to connect successfully (failure);

Returns

a Deferred that fires (with None) when we are “done” or with a Failure if something went wrong.

autobahn.twisted.component.run(components: List[Component], log_level: str = 'info', stop_at_close: bool = True)[source]

High-level API to run a series of components.

This will only return once all the components have stopped (including, possibly, after all re-connections have failed if you have re-connections enabled). Under the hood, this calls twisted.internet.reactor.run() – if you wish to manage the reactor loop yourself, use the autobahn.twisted.component.Component.start() method to start each component yourself.

Parameters
  • components – the Component(s) you wish to run

  • log_level – a valid log-level (or None to avoid calling start_logging)

  • stop_at_close – Flag to control whether to stop the reactor when done.