LumericalPersistentPythonSession#

class ansys.lumerical.mcp.persistent_session.LumericalPersistentPythonSession(python_executable: str | None = None, startup_code: str | None = None, working_directory: str | None = None)#

Bases: ansys.common.mcp.helpers.PersistentPythonSession

A PersistentPythonSession that tolerates long, silent operations.

execute() blocks indefinitely on a per-call completion marker; hung calls are recovered out-of-band by the restart_session MCP tool, which invokes PersistentPythonSession.restart().

Overview#

execute

Execute Python code in the persistent session.

Import detail#

from ansys.lumerical.mcp.persistent_session import LumericalPersistentPythonSession

Method detail#

LumericalPersistentPythonSession.execute(code: str) dict[str, Any]#

Execute Python code in the persistent session.

Parameters:
codestr

Python source to feed to the persistent python -u -i process.

Returns:
dict[str, Any]

Same shape as PersistentPythonSession.execute(){"success", "stdout", "stderr", "error"}.