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 2929RENEW_ERRORS = (ONVIFError , httpx .RequestError , XMLParseError , * SUBSCRIPTION_ERRORS )
3030SUBSCRIPTION_RESTART_INTERVAL_ON_ERROR = dt .timedelta (seconds = 40 )
3131
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
3236
3337if TYPE_CHECKING :
3438 from onvif .client import ONVIFCamera , ONVIFService
@@ -116,7 +120,10 @@ def _calculate_next_renewal_call_at(self, result: Any | None) -> float:
116120 delay = termination_time - current_time
117121 else :
118122 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+ )
120127 logger .debug (
121128 "%s: Renew notification subscription in %s seconds" ,
122129 self ._device .host ,
@@ -141,7 +148,7 @@ def _run_restart_or_renew(self) -> None:
141148 self ._renew_or_restart_subscription ()
142149 )
143150
144- async def _restart_subscription (self ) -> bool :
151+ async def _restart_subscription (self ) -> float :
145152 """Restart the notify subscription assuming the camera rebooted."""
146153 self ._cancel_renewals ()
147154 return await self ._start ()
You can’t perform that action at this time.
0 commit comments