@@ -257,17 +257,6 @@ async def __post(self, url, data):
257257
258258 return result
259259
260- @backoff .on_exception (
261- backoff .expo ,
262- (
263- AuthenticationException ,
264- LoginRetryErrorException ,
265- LoginTimeoutException ,
266- InvalidSessionException ,
267- ),
268- max_tries = 2 ,
269- on_backoff = retry_login ,
270- )
271260 async def __api_request_async (self , actions , priority = False ):
272261 """Build request to the internal JSON-req API."""
273262 self .__generate_request_id ()
@@ -376,6 +365,17 @@ async def get_encryption_method(self):
376365
377366 return None
378367
368+ @backoff .on_exception (
369+ backoff .expo ,
370+ (
371+ AuthenticationException ,
372+ LoginRetryErrorException ,
373+ LoginTimeoutException ,
374+ InvalidSessionException ,
375+ ),
376+ max_tries = 1 ,
377+ on_backoff = retry_login ,
378+ )
379379 async def get_value_by_xpath (self , xpath : str , options : dict | None = None ) -> dict :
380380 """
381381 Retrieve raw value from router using XPath.
@@ -395,6 +395,17 @@ async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> d
395395
396396 return data
397397
398+ @backoff .on_exception (
399+ backoff .expo ,
400+ (
401+ AuthenticationException ,
402+ LoginRetryErrorException ,
403+ LoginTimeoutException ,
404+ InvalidSessionException ,
405+ ),
406+ max_tries = 1 ,
407+ on_backoff = retry_login ,
408+ )
398409 async def get_values_by_xpaths (self , xpaths , options : dict | None = None ) -> dict :
399410 """
400411 Retrieve raw values from router using XPath.
@@ -418,6 +429,17 @@ async def get_values_by_xpaths(self, xpaths, options: dict | None = None) -> dic
418429
419430 return data
420431
432+ @backoff .on_exception (
433+ backoff .expo ,
434+ (
435+ AuthenticationException ,
436+ LoginRetryErrorException ,
437+ LoginTimeoutException ,
438+ InvalidSessionException ,
439+ ),
440+ max_tries = 1 ,
441+ on_backoff = retry_login ,
442+ )
421443 async def set_value_by_xpath (
422444 self , xpath : str , value : str , options : dict | None = None
423445 ) -> dict :
@@ -440,6 +462,17 @@ async def set_value_by_xpath(
440462
441463 return response
442464
465+ @backoff .on_exception (
466+ backoff .expo ,
467+ (
468+ AuthenticationException ,
469+ LoginRetryErrorException ,
470+ LoginTimeoutException ,
471+ InvalidSessionException ,
472+ ),
473+ max_tries = 1 ,
474+ on_backoff = retry_login ,
475+ )
443476 async def get_device_info (self ) -> DeviceInfo :
444477 """Retrieve information about Sagemcom F@st device."""
445478 try :
@@ -460,6 +493,17 @@ async def get_device_info(self) -> DeviceInfo:
460493
461494 return DeviceInfo (** data )
462495
496+ @backoff .on_exception (
497+ backoff .expo ,
498+ (
499+ AuthenticationException ,
500+ LoginRetryErrorException ,
501+ LoginTimeoutException ,
502+ InvalidSessionException ,
503+ ),
504+ max_tries = 1 ,
505+ on_backoff = retry_login ,
506+ )
463507 async def get_hosts (self , only_active : bool | None = False ) -> list [Device ]:
464508 """Retrieve hosts connected to Sagemcom F@st device."""
465509 data = await self .get_value_by_xpath (
@@ -473,13 +517,35 @@ async def get_hosts(self, only_active: bool | None = False) -> list[Device]:
473517
474518 return devices
475519
520+ @backoff .on_exception (
521+ backoff .expo ,
522+ (
523+ AuthenticationException ,
524+ LoginRetryErrorException ,
525+ LoginTimeoutException ,
526+ InvalidSessionException ,
527+ ),
528+ max_tries = 1 ,
529+ on_backoff = retry_login ,
530+ )
476531 async def get_port_mappings (self ) -> list [PortMapping ]:
477532 """Retrieve configured Port Mappings on Sagemcom F@st device."""
478533 data = await self .get_value_by_xpath ("Device/NAT/PortMappings" )
479534 port_mappings = [PortMapping (** p ) for p in data ]
480535
481536 return port_mappings
482537
538+ @backoff .on_exception (
539+ backoff .expo ,
540+ (
541+ AuthenticationException ,
542+ LoginRetryErrorException ,
543+ LoginTimeoutException ,
544+ InvalidSessionException ,
545+ ),
546+ max_tries = 1 ,
547+ on_backoff = retry_login ,
548+ )
483549 async def reboot (self ):
484550 """Reboot Sagemcom F@st device."""
485551 action = {
0 commit comments