Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
1.A big upgrade, improved a lot of areas, make up for the past many deficiencies.
2.Parameter annotations have been greatly improved, covering almost all parameters.
3.Improved exceptions, warning, and `msg` methods in `GqylpyException`.
4.Improved process for obtaining the logger (Get the logger during initialization, not on every call, greatly improve the execution speed).
5.Fixed the error when actively raise `ParameterError` exception.
6.Remove decorators `TryExceptAsync` and `RetryAsync` and integrate them into `TryExcept` and `Retry` (Still available in the current version,removed in the next version definite).
7.Deprecate parameters `ignore` and `output_raw_exc` in `TryExcept` and `Retry`, replaced to `silent_exc` and `raw_exc`.
  • Loading branch information
2018-11-27 committed Apr 15, 2023
1 parent f1da5e9 commit 8756de6
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 319 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ def func():
默认的处理流程是将异常简要信息输出到终端。当然,也可以输出到文件或做其它处理,通过参数控制:
```python
def TryExcept(
etype: Union[type, Tuple[type, ...]],
/, *,
ignore: bool = False,
output_raw_exc: bool = False,
logger: logging.Logger = None,
ereturn: Any = None,
ecallback: Callable[[Exception, Callable, ...], None] = None,
eexit: bool = False
etype: Union[ExceptionTypes],
*,
silent_exc: Optional[bool] = None,
raw_exc: Optional[bool] = None,
logger: Optional[ExceptionLogger] = None,
ereturn: Optional[Any] = None,
ecallback: Optional[ExceptionCallback] = None,
eexit: Optional[bool] = None
):
...
```
__参数 `etype`__<br>
要处理哪种异常,使用元祖传入多个。

__参数 `ingore`__<br>
__参数 `silent_exc`__<br>
设为 `True` 将静默处理异常,没有任何输出。

__参数 `output_raw_exc`__<br>
设为 `True` 将输出完整的异常信息,注意其优先级低于 `ignore`
__参数 `raw_exc`__<br>
设为 `True` 将输出完整的异常信息,注意其优先级低于 `silent_exc`

__参数 `logger`__<br>
接收一个日志记录器对象,`TryExcept` 希望使用日志记录器输出异常信息,它调用日志记录器的 `error` 方法。<br>
Expand Down Expand Up @@ -98,13 +98,13 @@ def func():
像上面这样调用 `Retry(count=3, cycle=1)` 表示最大执行3次,每次间隔1秒。完整的参数如下:
```python
def Retry(
etype: Union[type, Tuple[type, ...]] = Exception,
etype: Optional[ExceptionTypes] = None,
*,
count: int = inf,
cycle: Union[int, float] = 0,
ignore: bool = False,
output_raw_exc: bool = False,
logger: logging.Logger = None
count: Optional[int] = inf,
cycle: Optional[Union[int, float]] = 0,
silent_exc: Optional[bool] = None,
raw_exc: Optional[bool] = None,
logger: Optional[ExceptionLogger] = None
):
...
```
Expand Down
Loading

0 comments on commit 8756de6

Please sign in to comment.