def _connection_checker(func):
 @functools.wraps(func)
 def inner_connection_checker(self, *args, **kwargs):
  LOG.debug('in _connection_checker')
  for attempts in range(2):
   try:
    return func(self, *args, **kwargs)
   except exception.SynoAuthError as e:
    if (attempts < 1):
     LOG.debug('Session might have expired. Trying to relogin')
     self.new_session()
     continue
    else:
     LOG.error(_LE('Try to renew session: [%s]'), e)
     raise
 return inner_connection_checker

def _connection_checker ( func ) : @ functools . wraps ( func ) def inner_connection_checker ( self , * args , ** kwargs ) : LOG . debug ( 'in _connection_checker' ) for attempts in range ( 2 ) : try : return func ( self , * args , ** kwargs ) except exception . SynoAuthError as e : if ( attempts < 1 ) : LOG . debug ( 'Session might have expired. Trying to relogin' ) self . new_session ( ) continue else : LOG . error ( _LE ( 'Try to renew session: [%s]' ) , e ) raise return inner_connection_checker
decorator to check session has expired or not .