"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-06 21:20:54.403550
"""

```python
from typing import Any, Callable


class FallbackExecutor:
    """
    A class for creating a fallback mechanism that can be used when an operation fails.

    :param primary_action: The main function to execute.
    :param backup_action: The secondary action to take if the primary function fails.
    """

    def __init__(self, primary_action: Callable[[], Any], backup_action: Callable[[], Any] = None):
        self.primary_action = primary_action
        self.backup_action = backup_action

    def execute(self) -> Any:
        """
        Execute the primary action. If it raises an exception, attempt to run the backup action.
        Return the result of the executed function or a default value if both fail.

        :return: The result of the executed action or None in case of failure.
        """
        try:
            return self.primary_action()
        except Exception as e:
            print(f"Primary action failed with error: {e}")
            if self.backup_action is not None:
                try:
                    return self.backup_action()
                except Exception as e2:
                    print(f"Backup action also failed with error: {e2}")
                    return None
            else:
                return None


# Example usage
def primary_task():
    # Simulate a task that might fail
    import random
    if random.random() < 0.5:
        raise ValueError("Primary task execution failure")
    return "Success from primary task"

def backup_task():
    # Simulate a fallback task
    print("Executing backup task...")
    return "Fallback success"

# Create an instance of FallbackExecutor with both primary and backup actions
fallback_executor = FallbackExecutor(primary_task, backup_task)

result = fallback_executor.execute()
print(f"Final result: {result}")
```