Skip to content

Commit 66c8272

Browse files
committed
cover
1 parent 4c70073 commit 66c8272

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

onvif/client.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,13 @@ class AsyncTransportProtocolErrorHandler(AIOHTTPTransport):
114114
# once since
115115
"""
116116

117-
@retry_connection_error(
118-
attempts=2, exception=aiohttp.ServerDisconnectedError, backoff=0
119-
)
117+
@retry_connection_error(attempts=2, exception=aiohttp.ServerDisconnectedError)
120118
async def post(
121119
self, address: str, message: str, headers: dict[str, str]
122120
) -> httpx.Response:
123121
return await super().post(address, message, headers)
124122

125-
@retry_connection_error(
126-
attempts=2, exception=aiohttp.ServerDisconnectedError, backoff=0
127-
)
123+
@retry_connection_error(attempts=2, exception=aiohttp.ServerDisconnectedError)
128124
async def get(
129125
self,
130126
address: str,
@@ -133,14 +129,6 @@ async def get(
133129
) -> Response:
134130
return await super().get(address, params, headers)
135131

136-
@retry_connection_error(
137-
attempts=2, exception=aiohttp.ServerDisconnectedError, backoff=0
138-
)
139-
async def post_xml(
140-
self, address: str, envelope: Any, headers: dict[str, str]
141-
) -> Response:
142-
return await super().post_xml(address, envelope, headers)
143-
144132

145133
async def _cached_document(url: str) -> Document:
146134
"""Load external XML document from disk."""

onvif/wrappers.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
def retry_connection_error(
2020
attempts: int = DEFAULT_ATTEMPTS,
2121
exception: type[Exception] = aiohttp.ClientError,
22-
backoff: float | None = None,
2322
) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]:
2423
"""Define a wrapper to retry on connection error."""
25-
if backoff is None:
26-
backoff = BACKOFF_TIME
2724

2825
def _decorator_retry_connection_error(
2926
func: Callable[P, Awaitable[T]],
@@ -38,17 +35,8 @@ def _decorator_retry_connection_error(
3835
async def _async_wrap_connection_error_retry( # type: ignore[return]
3936
*args: P.args, **kwargs: P.kwargs
4037
) -> T:
41-
logger.debug(
42-
"retry_connection_error wrapper called for %s with exception=%s, attempts=%s",
43-
func.__name__,
44-
exception,
45-
attempts,
46-
)
4738
for attempt in range(attempts):
4839
try:
49-
logger.debug(
50-
"Attempt %s/%s for %s", attempt + 1, attempts, func.__name__
51-
)
5240
return await func(*args, **kwargs)
5341
except exception as ex:
5442
#
@@ -61,25 +49,16 @@ async def _async_wrap_connection_error_retry( # type: ignore[return]
6149
# to close the connection at any time, we treat this as a normal and try again
6250
# once since we do not want to declare the camera as not supporting PullPoint
6351
# if it just happened to close the connection at the wrong time.
64-
logger.debug(
65-
"Caught exception %s (type: %s) on attempt %s/%s",
66-
ex,
67-
type(ex).__name__,
68-
attempt + 1,
69-
attempts,
70-
exc_info=True,
71-
)
7252
if attempt == attempts - 1:
73-
logger.debug("Final attempt failed, re-raising exception")
7453
raise
7554
logger.debug(
7655
"Error: %s while calling %s, backing off: %s, retrying...",
7756
ex,
7857
func,
79-
backoff,
58+
BACKOFF_TIME,
8059
exc_info=True,
8160
)
82-
await asyncio.sleep(backoff)
61+
await asyncio.sleep(BACKOFF_TIME)
8362

8463
return _async_wrap_connection_error_retry
8564

0 commit comments

Comments
 (0)