engine#

Product-agnostic resilient-mode engine.

This package depends only on the Python standard library. It talks to a product exclusively through a ResilientAdapter, and its modules import each other with relative imports only, so it can move to a standalone distribution without code changes. A unit test enforces that no module here imports a product package.

Classes:

Checkpoint(name, path, include_data[, ...])

A restorable checkpoint written by the product (for example a case file).

CheckpointConfig([directory, keep_last, ...])

Where and how checkpoints are written.

Classification(category, severity, message)

Result of classifying an exception.

CommandOp(path, command[, args, ...])

A command executed with execute_cmd.

ErrorCategory(value[, names, module, ...])

Machine-readable classification of an error raised by a settings call.

ErrorClasses([read_only])

Exception classes a product raises for settings errors.

EventKind(value[, names, module, qualname, ...])

Kinds of events reported by a resilient session.

Journal(*[, max_ops])

Ordered, bounded record of state-changing operations with undo / redo.

ObjectOp(method, path[, args, seq, created_at])

A structural change: create, delete, rename or a list resize.

PoolConfig([size, launch_kwargs, launcher])

Warm standby sessions used for failover.

ResilientAdapter()

Product-specific behavior required by the resilient engine.

ResilientConfig([auto_checkpoint, ...])

Configuration of resilient mode.

ResilientController(session, config, adapter, *)

Resilient state of one session: journal, checkpoints, recovery and failover.

ResilientEvent(kind, message[, path, data])

An event reported to listeners registered with on_event.

ResilientSession(controller)

Resilient-mode controls of a session, available as session.resilient.

SetOp(path, new_value[, old_value, ...])

A value written with set_var.

Severity(value[, names, module, qualname, ...])

How the engine responds to a classified error.

StepOutcome(path, ok[, old_value, ...])

Outcome of one intercepted settings write or command.

WarmSessionPool(active, *, size, launcher, ...)

One active session plus size - 1 warm standby sessions.

Exceptions:

CheckpointError

Raised when a checkpoint cannot be written, found, or restored.

FailoverError

Raised when a standby session cannot take over from a dead session.

ResilientError

Base class for errors raised by the resilient engine itself.

ResilientFailoverWarning

A standby session took over from a session that died.

ResilientWarning

Base class for warnings emitted by resilient mode.

Functions:

disable_resilient_mode(session)

Disable resilient mode on session.

enable_resilient_mode(session[, config, ...])

Enable resilient mode on a live session.

is_resilient(session)

Return whether resilient mode is enabled on session.

class ansys.fluent.core.resilient.engine.Checkpoint(name, path, include_data, reason=None, journal_seq=0, created_at=<factory>)#

Bases: object

A restorable checkpoint written by the product (for example a case file).

Attributes:

created_at

include_data

journal_seq

Journal position when the checkpoint was taken.

name

path

reason

Methods:

to_dict()

Return the checkpoint metadata as a plain dictionary.

created_at: float#
include_data: bool#
journal_seq: int = 0#

Journal position when the checkpoint was taken. Journal operations with a sequence number at or above this value happened after the checkpoint.

name: str#
path: str#
reason: str | None = None#
to_dict()#

Return the checkpoint metadata as a plain dictionary.

class ansys.fluent.core.resilient.engine.CheckpointConfig(directory=None, keep_last=5, include_data=True)#

Bases: object

Where and how checkpoints are written.

Parameters:
directorystr or os.PathLike, optional

Directory for checkpoint files. For a server that shares the client file system, the default is resilient_checkpoints/<run-id> under the current working directory. For a remote or containerized server, the default is the server working directory (for a container, the folder mounted into it), and a directory you give is a path on the server (for a container, a path inside it). It must already exist, and every standby session must be able to read it.

keep_lastint, optional

Number of most recent checkpoints to keep. Older ones are deleted when the client can reach the files. The default is 5.

include_databool, optional

Whether to include solution data when the product supports it. The default is True.

Attributes:

directory: str | PathLike | None = None#
include_data: bool = True#
keep_last: int = 5#
exception ansys.fluent.core.resilient.engine.CheckpointError#

Bases: ResilientError

Raised when a checkpoint cannot be written, found, or restored.

class ansys.fluent.core.resilient.engine.Classification(category, severity, message, details=None)#

Bases: object

Result of classifying an exception.

Attributes:

benign

Whether this is a clean solver stop rather than an error.

catastrophic

Whether this error makes the session unusable.

category

details

message

severity

property benign: bool#

Whether this is a clean solver stop rather than an error.

property catastrophic: bool#

Whether this error makes the session unusable.

category: ErrorCategory#
details: str | None = None#
message: str#
severity: Severity#
class ansys.fluent.core.resilient.engine.CommandOp(path, command, args=<factory>, irreversible=False, checkpoint=None, seq=-1, created_at=<factory>)#

Bases: object

A command executed with execute_cmd.

Attributes:

args

checkpoint

command

created_at

full_path

Return the command path including the command name.

irreversible

kind

path

seq

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

args: dict[str, Any]#
checkpoint: str | None = None#
command: str#
created_at: float#
describe()#

Return a one-line description of the operation.

property full_path: str#

Return the command path including the command name.

irreversible: bool = False#
kind: ClassVar[str] = 'command'#
path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.

class ansys.fluent.core.resilient.engine.ErrorCategory(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

Machine-readable classification of an error raised by a settings call.

Attributes:

BENIGN_INTERRUPT

A clean stop of an interruptible (solve) command.

FATAL

The server is in a fatal state or no longer serving.

READ_ONLY

The target is read-only.

UNKNOWN

None of the above.

BENIGN_INTERRUPT = 'benign_interrupt'#

A clean stop of an interruptible (solve) command.

FATAL = 'fatal'#

The server is in a fatal state or no longer serving.

READ_ONLY = 'read_only'#

The target is read-only.

UNKNOWN = 'unknown'#

None of the above.

class ansys.fluent.core.resilient.engine.ErrorClasses(read_only=None)#

Bases: object

Exception classes a product raises for settings errors.

Any member may be None; the classifier then relies on message heuristics.

Attributes:

read_only: type | None = None#
class ansys.fluent.core.resilient.engine.EventKind(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: str, Enum

Kinds of events reported by a resilient session.

Attributes:

CHECKPOINT

A checkpoint was written.

FAILOVER

A standby session took over from a session that died.

REDO

A journaled settings write was redone.

ROLLBACK

The session was restored to a checkpoint.

UNDO

A journaled settings write was undone.

Methods:

__new__(value)

CHECKPOINT = 'checkpoint'#

A checkpoint was written.

FAILOVER = 'failover'#

A standby session took over from a session that died.

REDO = 'redo'#

A journaled settings write was redone.

ROLLBACK = 'rollback'#

The session was restored to a checkpoint.

UNDO = 'undo'#

A journaled settings write was undone.

__new__(value)#
exception ansys.fluent.core.resilient.engine.FailoverError#

Bases: ResilientError

Raised when a standby session cannot take over from a dead session.

class ansys.fluent.core.resilient.engine.Journal(*, max_ops=10000)#

Bases: object

Ordered, bounded record of state-changing operations with undo / redo.

Parameters:
max_opsint, optional

Maximum number of operations kept. When exceeded, the oldest operations are dropped (replay from before that point is then impossible and a failover requires a newer checkpoint).

Methods:

__init__(*[, max_ops])

can_redo()

Return whether there is an undone operation to redo.

can_undo()

Return whether there is an operation to undo.

live_since(seq)

Return the live operations with a sequence number of at least seq.

record(op)

Append an operation, discarding any undone operations after the cursor.

redo(write)

Re-apply the most recently undone value write.

to_script()

Return the live operations as plain dictionaries.

truncate(seq)

Forget every operation with a sequence number of at least seq.

undo(write)

Undo the most recent value write by writing back its previous value.

Attributes:

next_seq

Sequence number the next recorded operation receives.

operations

Return the live operations (oldest first).

__init__(*, max_ops=10000)#
can_redo()#

Return whether there is an undone operation to redo.

can_undo()#

Return whether there is an operation to undo.

live_since(seq)#

Return the live operations with a sequence number of at least seq.

Raises:
ResilientError

If operations after seq were already dropped from the journal.

property next_seq: int#

Sequence number the next recorded operation receives.

property operations: list[SetOp | CommandOp | ObjectOp]#

Return the live operations (oldest first).

record(op)#

Append an operation, discarding any undone operations after the cursor.

redo(write)#

Re-apply the most recently undone value write.

Raises:
ResilientError

If there is nothing to redo.

to_script()#

Return the live operations as plain dictionaries.

truncate(seq)#

Forget every operation with a sequence number of at least seq.

undo(write)#

Undo the most recent value write by writing back its previous value.

Raises:
ResilientError

If there is nothing to undo, if the most recent operation is not a value write, or if its previous value was not captured.

class ansys.fluent.core.resilient.engine.ObjectOp(method, path, args=(), seq=-1, created_at=<factory>)#

Bases: object

A structural change: create, delete, rename or a list resize.

Attributes:

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

args: tuple[Any, ...] = ()#
created_at: float#
describe()#

Return a one-line description of the operation.

kind: ClassVar[str] = 'object'#
method: str#
path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.

class ansys.fluent.core.resilient.engine.PoolConfig(size=1, launch_kwargs=None, launcher=None)#

Bases: object

Warm standby sessions used for failover.

Parameters:
sizeint, optional

Total number of sessions: one active session plus size - 1 warm standbys. The default is 1 (no standbys, no failover).

launch_kwargsdict, optional

Keyword arguments for the product’s launch function, used to start standbys. When omitted, standbys reuse the arguments that launched the active session if they are known.

launchercallable(), optional

Zero-argument callable that returns a new session. Takes precedence over launch_kwargs.

Attributes:

launch_kwargs: dict[str, Any] | None = None#
launcher: Optional[Callable[[], Any]] = None#
size: int = 1#
class ansys.fluent.core.resilient.engine.ResilientAdapter#

Bases: ABC

Product-specific behavior required by the resilient engine.

Subclasses must implement the abstract methods. Every other method has a default that suits sessions exposing a settings root and a _settings_service attribute.

Methods:

can_checkpoint(session)

Return whether the session currently holds state worth checkpointing.

checkpoint_artifacts(file_path, *, include_data)

Return every file a checkpoint written to file_path consists of.

command_name(command_path)

Return the normalized last segment of a command path.

error_classes()

Return the exception classes the product raises for settings errors.

exit_session(session)

Exit a session.

fatal_details(session)

Return details of a fatal error, if any.

invalidate_settings_cache(session)

Drop the cached settings root so that it is rebuilt on next access.

is_fatal(session)

Return whether the product reported a fatal error for the session.

is_interrupt(err)

Return whether err is the product's clean stop of a command.

is_interruptible(command_path)

Return whether a command may stop with the clean-stop sentinel.

is_irreversible(command_path)

Return whether a command cannot be undone by setting values.

is_replayable(command_path)

Return whether a recorded command is replayed onto a standby session.

is_server_healthy(session)

Return whether the server answers a health check.

launch(**kwargs)

Launch a new session with the product's launch function.

read_checkpoint(session, file_path, *, ...)

Restore the session from the checkpoint at file_path.

register_exit_callback(session, callback)

Register callback to run when session exits.

set_settings_service(session, service)

Install a settings service on a session.

settings_root(session)

Return the settings root of a session.

settings_service(session)

Return the settings service of a session, or None.

shares_client_filesystem(session)

Return whether the server reads and writes the client's file system.

standby_launcher(session)

Return a callable that launches a session like session, if known.

write_checkpoint(session, file_path, *, ...)

Write a checkpoint of the session to file_path.

Attributes:

checkpoint_suffix

File suffix of a checkpoint artifact.

interruptible_commands

Commands for which the clean-stop sentinel is a benign interrupt.

irreversible_commands

Command names that cannot be undone by setting values (a checkpoint is written before them when auto_checkpoint is enabled).

non_replayable_commands

Commands that are recorded but never replayed onto a standby session.

non_replayable_prefixes

Command-name prefixes that are recorded but never replayed (for example commands that only write output files).

path_prefixes

Dotted prefixes a user may prepend to a settings path.

product_name

Product name used in messages.

server_name_attr

Attribute holding the server-side name of a settings object.

can_checkpoint(session)#

Return whether the session currently holds state worth checkpointing.

checkpoint_artifacts(file_path, *, include_data)#

Return every file a checkpoint written to file_path consists of.

checkpoint_suffix: str = ''#

File suffix of a checkpoint artifact.

static command_name(command_path)#

Return the normalized last segment of a command path.

Server-side names such as "solution/run-calculation/read-case" are normalized to Python-style names ("read_case") so that adapters can list commands by their Python names.

error_classes()#

Return the exception classes the product raises for settings errors.

exit_session(session)#

Exit a session. Must never raise.

fatal_details(session)#

Return details of a fatal error, if any.

interruptible_commands: frozenset[str] = frozenset({})#

Commands for which the clean-stop sentinel is a benign interrupt.

abstract invalidate_settings_cache(session)#

Drop the cached settings root so that it is rebuilt on next access.

irreversible_commands: frozenset[str] = frozenset({})#

Command names that cannot be undone by setting values (a checkpoint is written before them when auto_checkpoint is enabled).

abstract is_fatal(session)#

Return whether the product reported a fatal error for the session.

is_interrupt(err)#

Return whether err is the product’s clean stop of a command.

Only consulted for interruptible_commands. The default is False.

is_interruptible(command_path)#

Return whether a command may stop with the clean-stop sentinel.

is_irreversible(command_path)#

Return whether a command cannot be undone by setting values.

is_replayable(command_path)#

Return whether a recorded command is replayed onto a standby session.

abstract is_server_healthy(session)#

Return whether the server answers a health check. Must never raise.

launch(**kwargs)#

Launch a new session with the product’s launch function.

Raises:
NotImplementedError

If the product does not support launching standby sessions.

non_replayable_commands: frozenset[str] = frozenset({})#

Commands that are recorded but never replayed onto a standby session.

non_replayable_prefixes: tuple[str, ...] = ()#

Command-name prefixes that are recorded but never replayed (for example commands that only write output files).

path_prefixes: tuple[str, ...] = ('settings.',)#

Dotted prefixes a user may prepend to a settings path.

product_name: str = 'product'#

Product name used in messages.

abstract read_checkpoint(session, file_path, *, include_data)#

Restore the session from the checkpoint at file_path.

register_exit_callback(session, callback)#

Register callback to run when session exits.

Returns whether the callback was registered.

server_name_attr: str = 'obj_name'#

Attribute holding the server-side name of a settings object.

set_settings_service(session, service)#

Install a settings service on a session.

settings_root(session)#

Return the settings root of a session.

settings_service(session)#

Return the settings service of a session, or None.

shares_client_filesystem(session)#

Return whether the server reads and writes the client’s file system.

standby_launcher(session)#

Return a callable that launches a session like session, if known.

abstract write_checkpoint(session, file_path, *, include_data)#

Write a checkpoint of the session to file_path.

Returns whether solution data was included.

class ansys.fluent.core.resilient.engine.ResilientConfig(auto_checkpoint=True, auto_rollback=True, journal_max_ops=10000, checkpoint=<factory>, pool=<factory>)#

Bases: object

Configuration of resilient mode.

Parameters:
auto_checkpointbool, optional

Whether to write a checkpoint before each irreversible command (for example iterate or read_case). The default is True.

auto_rollbackbool, optional

Whether to restore that checkpoint when the irreversible command fails. The original error is raised afterwards in either case. The default is True.

journal_max_opsint, optional

Maximum number of operations kept in the journal. The default is 10000.

checkpointCheckpointConfig, optional

Checkpoint location and retention.

poolPoolConfig, optional

Warm standby sessions for failover.

Attributes:

auto_checkpoint: bool = True#
auto_rollback: bool = True#
checkpoint: CheckpointConfig#
journal_max_ops: int = 10000#
pool: PoolConfig#
class ansys.fluent.core.resilient.engine.ResilientController(session, config, adapter, *, pool=None, journal_complete=False)#

Bases: object

Resilient state of one session: journal, checkpoints, recovery and failover.

The controller is created by enable_resilient_mode(); users interact with it through session.resilient.

Parameters:
sessionobject

The product session.

configResilientConfig

Resilient-mode configuration.

adapterResilientAdapter

The product adapter.

poolWarmSessionPool, optional

Warm standby sessions for failover.

journal_completebool, optional

Whether the journal records the session from its launch, so that a standby launched the same way can be brought to the same state by replaying it.

Methods:

__init__(session, config, adapter, *[, ...])

apply_command(path, command, kwds)

Handle an intercepted execute_cmd call.

apply_object_change(method, path, args)

Handle an intercepted create / delete / rename / resize call.

apply_query(method, args, kwargs)

Handle a delegated read; fail over if the server died.

apply_set(path, value)

Handle an intercepted set_var call.

bind(session)

Route session's settings calls through this controller.

checkpoint(name)

Write a checkpoint called name.

disable()

Stop intercepting settings calls and exit the standby sessions.

on_event(listener)

Register a listener called with every ResilientEvent.

redo()

Re-apply the most recently undone value write.

rollback([name])

Restore the newest checkpoint, or the newest one called name.

undo()

Undo the most recent value write.

wait_for_standbys([timeout])

Wait until every standby applied the changes queued for it.

__init__(session, config, adapter, *, pool=None, journal_complete=False)#
apply_command(path, command, kwds)#

Handle an intercepted execute_cmd call.

apply_object_change(method, path, args)#

Handle an intercepted create / delete / rename / resize call.

apply_query(method, args, kwargs)#

Handle a delegated read; fail over if the server died.

Reads have no side effects, so a read that fails because the server died is repeated on the standby that takes over.

Raises:
Exception

The error of the read when it is not caused by a dead server, or when no standby is configured.

apply_set(path, value)#

Handle an intercepted set_var call.

bind(session)#

Route session’s settings calls through this controller.

checkpoint(name)#

Write a checkpoint called name.

Raises:
CheckpointError

If the session has nothing to checkpoint or the write fails.

disable()#

Stop intercepting settings calls and exit the standby sessions.

on_event(listener)#

Register a listener called with every ResilientEvent.

redo()#

Re-apply the most recently undone value write.

Raises:
ResilientError

If there is nothing to redo.

rollback(name=None)#

Restore the newest checkpoint, or the newest one called name.

Newer checkpoints and the journal entries recorded after the restored checkpoint are discarded.

Raises:
CheckpointError

If no matching checkpoint exists or the restore fails.

undo()#

Undo the most recent value write.

Raises:
ResilientError

If the most recent operation cannot be undone.

wait_for_standbys(timeout=None)#

Wait until every standby applied the changes queued for it.

Returns:
bool

Whether every standby applied them within timeout seconds and is in sync with the active session.

exception ansys.fluent.core.resilient.engine.ResilientError#

Bases: RuntimeError

Base class for errors raised by the resilient engine itself.

class ansys.fluent.core.resilient.engine.ResilientEvent(kind, message, path=None, data=<factory>)#

Bases: object

An event reported to listeners registered with on_event.

Attributes:

data: dict[str, Any]#
kind: EventKind#
message: str#
path: str | None = None#
exception ansys.fluent.core.resilient.engine.ResilientFailoverWarning#

Bases: ResilientWarning

A standby session took over from a session that died.

class ansys.fluent.core.resilient.engine.ResilientSession(controller)#

Bases: object

Resilient-mode controls of a session, available as session.resilient.

Methods:

__init__(controller)

checkpoint(name)

Write a checkpoint that rollback() can restore.

disable()

Turn resilient mode off and exit the standby sessions.

on_event(listener)

Call listener with every ResilientEvent of the session.

redo()

Re-apply the most recently undone settings value write.

rollback([name])

Restore the newest checkpoint, or the newest one called name.

undo()

Undo the most recent settings value write.

wait_for_standbys([timeout])

Wait until the standby sessions applied every change made so far.

Attributes:

active_session

The session that currently serves settings calls.

adapter

The product adapter.

checkpoints

The retained checkpoints, oldest first.

config

The resilient-mode configuration.

enabled

Whether resilient mode is active on the session.

journal

The journal of state-changing operations.

last_outcome

The outcome of the most recent intercepted write or command.

pool

The warm standby pool, or None when failover is not enabled.

__init__(controller)#
property active_session: Any#

The session that currently serves settings calls.

This is the original session until a failover, and the standby session that took over afterwards.

property adapter: ResilientAdapter#

The product adapter.

checkpoint(name)#

Write a checkpoint that rollback() can restore.

Parameters:
namestr

Name of the checkpoint.

Returns:
Checkpoint

The written checkpoint.

property checkpoints: list[Checkpoint]#

The retained checkpoints, oldest first.

property config: ResilientConfig#

The resilient-mode configuration.

disable()#

Turn resilient mode off and exit the standby sessions.

property enabled: bool#

Whether resilient mode is active on the session.

property journal: Journal#

The journal of state-changing operations.

property last_outcome: StepOutcome | None#

The outcome of the most recent intercepted write or command.

on_event(listener)#

Call listener with every ResilientEvent of the session.

Parameters:
listenercallable()

Called with one ResilientEvent argument.

property pool: WarmSessionPool | None#

The warm standby pool, or None when failover is not enabled.

redo()#

Re-apply the most recently undone settings value write.

Returns:
SetOp

The redone operation.

rollback(name=None)#

Restore the newest checkpoint, or the newest one called name.

Checkpoints written after it, and journal entries recorded after it, are discarded.

Parameters:
namestr, optional

Name of the checkpoint to restore.

Returns:
Checkpoint

The restored checkpoint.

undo()#

Undo the most recent settings value write.

Returns:
SetOp

The undone operation.

wait_for_standbys(timeout=None)#

Wait until the standby sessions applied every change made so far.

Changes that succeed on the active session are applied to the standbys in the background. A failover already waits for them, so calling this is only needed to know that the standbys are up to date.

Parameters:
timeoutfloat, optional

Maximum time to wait, in seconds. The default is None, which waits as long as needed.

Returns:
bool

Whether every standby applied the changes in time and is in sync with the active session.

exception ansys.fluent.core.resilient.engine.ResilientWarning#

Bases: UserWarning

Base class for warnings emitted by resilient mode.

class ansys.fluent.core.resilient.engine.SetOp(path, new_value, old_value=None, old_value_known=False, seq=-1, created_at=<factory>)#

Bases: object

A value written with set_var.

Attributes:

created_at

kind

new_value

old_value

old_value_known

Whether old_value was read before the write (required for undo).

path

seq

Methods:

describe()

Return a one-line description of the operation.

to_dict()

Return the operation as a plain dictionary.

created_at: float#
describe()#

Return a one-line description of the operation.

kind: ClassVar[str] = 'set'#
new_value: Any#
old_value: Any = None#
old_value_known: bool = False#

Whether old_value was read before the write (required for undo).

path: str#
seq: int = -1#
to_dict()#

Return the operation as a plain dictionary.

class ansys.fluent.core.resilient.engine.Severity(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#

Bases: Enum

How the engine responds to a classified error.

Attributes:

BENIGN

Not an error (clean solver stop).

CATASTROPHIC

The session is unusable; fail over to a standby session if one exists.

HARD

Not catastrophic; the original error is raised unchanged.

BENIGN = 'benign'#

Not an error (clean solver stop).

CATASTROPHIC = 'catastrophic'#

The session is unusable; fail over to a standby session if one exists.

HARD = 'hard'#

Not catastrophic; the original error is raised unchanged.

class ansys.fluent.core.resilient.engine.StepOutcome(path, ok, old_value=None, new_value=None, result=None, rolled_back=False, failed_over=False, error=None)#

Bases: object

Outcome of one intercepted settings write or command.

Attributes:

Methods:

to_dict()

Return the non-empty fields of the outcome as a plain dictionary.

error: str | None = None#
failed_over: bool = False#
new_value: Any = None#
ok: bool#
old_value: Any = None#
path: str#
result: Any = None#
rolled_back: bool = False#
to_dict()#

Return the non-empty fields of the outcome as a plain dictionary.

class ansys.fluent.core.resilient.engine.WarmSessionPool(active, *, size, launcher, adapter)#

Bases: object

One active session plus size - 1 warm standby sessions.

Parameters:
activeobject

The session in use.

sizeint

Total number of sessions, including the active one.

launchercallable()

Zero-argument callable that launches a standby session.

adapterResilientAdapter

The product adapter.

Raises:
ResilientError

If a standby session cannot be launched.

Methods:

__init__(active, *, size, launcher, adapter)

promote(standby, *[, retire_previous])

Make standby the active session; return the previous active session.

release(session)

Put back a standby that was taken but not promoted.

shutdown(*[, keep])

Exit every session of the pool except keep.

take_standby([prefer])

Remove and return a healthy standby session.

Attributes:

active

Return the active session.

on_standby_added

Called with each standby launched after the pool was created.

size

Return the configured number of sessions, including the active one.

standbys

Return the warm standby sessions.

__init__(active, *, size, launcher, adapter)#
property active: Any#

Return the active session.

on_standby_added: Optional[Callable[[Any], None]]#

Called with each standby launched after the pool was created.

promote(standby, *, retire_previous=True)#

Make standby the active session; return the previous active session.

The previous session is exited in the background unless retire_previous is False, and a replacement standby is launched in the background.

release(session)#

Put back a standby that was taken but not promoted.

shutdown(*, keep=None)#

Exit every session of the pool except keep.

property size: int#

Return the configured number of sessions, including the active one.

property standbys: list[Any]#

Return the warm standby sessions.

take_standby(prefer=None)#

Remove and return a healthy standby session.

Unhealthy standbys found on the way are exited.

Parameters:
prefercallable(), optional

Called with each healthy standby; the first one for which it returns True is taken. Otherwise the first healthy standby is taken.

Raises:
FailoverError

If no healthy standby is available.

ansys.fluent.core.resilient.engine.disable_resilient_mode(session)#

Disable resilient mode on session.

Settings calls go directly to the product again and the standby sessions are exited. Calling this on a session without resilient mode does nothing.

Parameters:
sessionobject

A product session.

Returns:
object

The same session.

ansys.fluent.core.resilient.engine.enable_resilient_mode(session, config=None, *, adapter, pool_size=None, standby_launcher=None, journal_complete=False)#

Enable resilient mode on a live session.

Parameters:
sessionobject

A live product session with a settings tree.

configResilientConfig, optional

Resilient-mode configuration. The default configuration is used when omitted. The object is not modified.

adapterResilientAdapter

The product adapter.

pool_sizeint, optional

Shortcut for config.pool.size.

standby_launchercallable(), optional

Zero-argument callable that launches a standby session like session. Product launch functions pass it; it is used only when the configuration does not say how to launch standbys.

journal_completebool, optional

Whether session was just launched, so that the journal records its whole history. Product launch functions pass True.

Returns:
object

The same session, with resilient controls available as session.resilient.

Raises:
ResilientError

If resilient mode is already enabled, the session has no settings service, or standby sessions cannot be launched.

ansys.fluent.core.resilient.engine.is_resilient(session)#

Return whether resilient mode is enabled on session.

Parameters:
sessionobject

A product session.

Returns:
bool

Whether resilient mode is enabled.