Skip to content

Commit 7ece75b

Browse files
committed
Add result_is_success() function
1 parent 5e5d1c1 commit 7ece75b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ result_callback_function (id: int, config, result, log: dict) -> Any
255255
```python
256256
def get_tps(logs: dict=None, debug: bool=False, interval: float=0, reverse_interval: bool = False, display_intervals: bool = False) -> dict:
257257
```
258-
The log dict matches the format of the [get_logs()](#get_logs) and refers to it by default. Each task within a log will be validated for success according to the [callback_function](#task.result_callback) result rule.
258+
The log dict matches the format of the [get_logs()](#get_logs) and refers to it by default.
259+
Each task within a log will be validated for success according to the [callback_function()](#task.result_callback) result rule.
259260

260261
### Scenarios
261262

src/worker_dispatcher/worker_dispatcher.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def _tps_calculate(started_at: float, ended_at: float, logs: list, display_valid
704704
exec_time_min = exec_time if not exec_time_min or exec_time < exec_time_min else exec_time_min
705705
# Success case check
706706
result = log['result']
707-
if (isinstance(result, requests.Response) and result.status_code != 200) or not result:
707+
if not result_is_success(result):
708708
continue
709709
# Rewrite success_id_set if in the argument
710710
if isinstance(success_id_set, set):
@@ -757,6 +757,12 @@ def _tps_calculate(started_at: float, ended_at: float, logs: list, display_valid
757757
def _validate_log_format(log) -> bool:
758758
return all(key in log for key in ('started_at', 'ended_at', 'result'))
759759

760+
def result_is_success(result) -> bool:
761+
if (isinstance(result, requests.Response) and result.status_code != 200) or not result:
762+
return False
763+
else:
764+
return True
765+
760766
def get_last_config() -> dict:
761767
return last_config
762768

0 commit comments

Comments
 (0)