qat.runtime.connection module

class ConnectionMode(value)

Bases: Flag

The connection mode can be used to specify how a Runtime should handle connections.

The method for connection handling will depend in the context in which the Runtime is used. For example, if a user only requires to send jobs sporadically, then a connection that is created before execution and ended after execution might be desired. On the contrary, if there is a stream of frequent jobs, the connection likely wants to be held indefinitely.

There are different flags that can be specified:

  1. ConnectionMode.CONNECT_BEFORE_EXECUTE: Specifies that the Runtime should attempt

    to connect the engine each time execute is called.

  2. ConnectionMode.DISCONNECT_AFTER_EXECUTE: Specifies that the Runtime should attempt

    to disconnect the engine after each execute.

  3. ConnectionMode.CONNECT_AT_BEGINNING: Specifies that the Runtime should attempt to

    connect the engine as soon as its instantiated.

  4. ConnectionMode.DISCONNECT_AT_END: Specifies that the Runtime should attempt to

    disconnect the engine when the Runtime is deleted (or at the end of a context manager).

Some predefined composite modes:

  1. ConnectionMode.MANUAL: Connection handling is done externally: the Runtime will

    make no attempt to manage it.

  2. ConnectionMode.DEFAULT: The connection will be created before each execution and

    disconnected immediately after the execution is complete.

  3. ConnectionMode.ALWAYS: A connection is created at instantiation of the Runtime,

    and is kept throughout the lifetime of the Runtime. It will not try to connect at execution.

  4. ConnectionMode.ALWAYS_ON_EXECUTE: A connection is attempted each time execution is

    called. However, the Runtime will not attempt to disconnect after execution is complete. This allows for external disconnection of the engine during e.g. idle periods, and for the connection to be restored when needed.

Warning

If a Runtime is not used with ConnectionMode.DEFAULT or ConnectionMode.ALWAYS_ON_EXECUTE, then external interference can cause undesired behaviour. Furthermore, the specifics of each mode might have slight variations depending on which Runtime is used (which should be well documented).

ALWAYS = 12
ALWAYS_ON_EXECUTE = 9
CONNECT_AT_BEGINNING = 4
CONNECT_BEFORE_EXECUTE = 1
DEFAULT = 3
DISCONNECT_AFTER_EXECUTE = 2
DISCONNECT_AT_END = 8
MANUAL = 16