You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a robust retry mechanism for operations in `autowsgr/ops` that involve user interaction (clicking) followed by state verification. The design must allow applying a decorator directly to the operation methods, avoiding nested function definitions.
-**Exception Handling**: Retrying when specific exceptions are raised.
12
+
-**No explicit validation callback**: The decorated function itself is expected to raise an exception if the operation fails (e.g., using `wait_leave_page` inside the function).
13
+
14
+
```python
15
+
# autowsgr/ops/retry.py
16
+
17
+
import functools
18
+
import time
19
+
from typing import Callable, TypeVar, Any, Sequence
For each target operation, we will define a dedicated method (if not already present) that performs the atomic action: **Action + Verification**. This method will be decorated with `@retry_action`.
if StartScreenPage.is_current_page(ctrl.screenshot()):
104
+
_enter_game(ctrl)
105
+
```
106
+
*Note: Since `startup.py` uses standalone functions, we can define the helper inside `start_game`or at module level. Defining it at module level (oras a private helper) is cleaner.*
107
+
108
+
## Verification Strategy
109
+
- The decorator relies on the wrapped function raising an exception.
110
+
-`wait_leave_page` raises `NavigationError`.
111
+
-`wait_for_game_ui` returns `bool`, so we must manually raise`TimeoutError`if it returns `False`.
0 commit comments