File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 29
29
RENEW_ERRORS = (ONVIFError , httpx .RequestError , XMLParseError , * SUBSCRIPTION_ERRORS )
30
30
SUBSCRIPTION_RESTART_INTERVAL_ON_ERROR = dt .timedelta (seconds = 40 )
31
31
32
+ # If the camera returns a subscription with a termination time that is less than
33
+ # this value, we will use this value instead to prevent subscribing over and over
34
+ # again.
35
+ MINIMUM_SUBSCRIPTION_SECONDS = 60.0
32
36
33
37
if TYPE_CHECKING :
34
38
from onvif .client import ONVIFCamera , ONVIFService
@@ -116,7 +120,10 @@ def _calculate_next_renewal_call_at(self, result: Any | None) -> float:
116
120
delay = termination_time - current_time
117
121
else :
118
122
delay = self ._interval
119
- delay_seconds = delay .total_seconds () * _RENEWAL_PERCENTAGE
123
+ delay_seconds = (
124
+ max (delay .total_seconds (), MINIMUM_SUBSCRIPTION_SECONDS )
125
+ * _RENEWAL_PERCENTAGE
126
+ )
120
127
logger .debug (
121
128
"%s: Renew notification subscription in %s seconds" ,
122
129
self ._device .host ,
@@ -141,7 +148,7 @@ def _run_restart_or_renew(self) -> None:
141
148
self ._renew_or_restart_subscription ()
142
149
)
143
150
144
- async def _restart_subscription (self ) -> bool :
151
+ async def _restart_subscription (self ) -> float :
145
152
"""Restart the notify subscription assuming the camera rebooted."""
146
153
self ._cancel_renewals ()
147
154
return await self ._start ()
You can’t perform that action at this time.
0 commit comments