def _retry(func):
 def wrapper(obj, *args, **kwargs):
  'Wrapper for all query functions.'
  update_retries = 5
  while (update_retries > 0):
   try:
    func(obj, *args, **kwargs)
    break
   except (OSError, TypeError, ValueError):
    update_retries -= 1
    if (update_retries == 0):
     obj.set_state(STATE_OFF)
 return wrapper

def _retry ( func ) : def wrapper ( obj , * args , ** kwargs ) : update_retries = 5 while ( update_retries > 0 ) : try : func ( obj , * args , ** kwargs ) break except ( OSError , TypeError , ValueError ) : update_retries -= 1 if ( update_retries == 0 ) : obj . set_state ( STATE_OFF ) return wrapper
decorator to handle query retries .