autobahn.twisted.choosereactor


Module Contents

Functions

current_reactor_klass()

Return class name of currently installed Twisted reactor or None.

install_optimal_reactor([require_optimal_reactor])

Try to install the optimal Twisted reactor for this platform:

install_reactor([explicit_reactor, verbose, log, ...])

Install Twisted reactor.

autobahn.twisted.choosereactor.current_reactor_klass()[source]

Return class name of currently installed Twisted reactor or None.

autobahn.twisted.choosereactor.install_optimal_reactor(require_optimal_reactor=True)[source]

Try to install the optimal Twisted reactor for this platform:

  • Linux: epoll

  • BSD/OSX: kqueue

  • Windows: iocp

  • Other: select

Notes:

  • This function exists, because the reactor types selected based on platform in twisted.internet.default are different from here.

  • The imports are inlined, because the Twisted code base is notorious for importing the reactor as a side-effect of merely importing. Hence we postpone all importing.

See: http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html#reactor-functionality

Parameters

require_optimal_reactor (bool) – If True and the desired reactor could not be installed, raise ReactorAlreadyInstalledError, else fallback to another reactor.

Returns

The Twisted reactor in place (twisted.internet.reactor).

autobahn.twisted.choosereactor.install_reactor(explicit_reactor=None, verbose=False, log=None, require_optimal_reactor=True)[source]

Install Twisted reactor.

Parameters
  • explicit_reactor (obj) – If provided, install this reactor. Else, install the optimal reactor.

  • verbose (bool) – If True, log (at level “info”) the reactor that is in place afterwards.

  • log (obj) – Explicit logging to this txaio logger object.

  • require_optimal_reactor (bool) – If True and the desired reactor could not be installed, raise ReactorAlreadyInstalledError, else fallback to another reactor.

Returns

The Twisted reactor in place (twisted.internet.reactor).