def _send_simple_push(endpoint, version, max_retries=3, _retry_count=0):
 try:
  r = requests.put(endpoint, 'version={}'.format(version))
 except RequestException as e:
  if (_retry_count < max_retries):
   return _send_simple_push(endpoint, version, max_retries, (_retry_count + 1))
  else:
   logger.error('SimplePush PUT failed: %s', e)
   return
 if (r.status_code >= 400):
  try:
   data = r.json()
  except simplejson.scanner.JSONDecodeError:
   logger.error('SimplePush error (also not JSON?!): %s %s', r.status_code, r.text)
   return
  if ((r.status_code == 503) and (data['errno'] == 202) and (_retry_count < max_retries)):
   return _send_simple_push(endpoint, version, max_retries, (_retry_count + 1))
  else:
   logger.error('SimplePush error: %s %s', r.status_code, r.json())

def _send_simple_push ( endpoint , version , max_retries = 3 , _retry_count = 0 ) : try : r = requests . put ( endpoint , 'version={}' . format ( version ) ) except RequestException as e : if ( _retry_count < max_retries ) : return _send_simple_push ( endpoint , version , max_retries , ( _retry_count + 1 ) ) else : logger . error ( 'SimplePush PUT failed: %s' , e ) return if ( r . status_code >= 400 ) : try : data = r . json ( ) except simplejson . scanner . JSONDecodeError : logger . error ( 'SimplePush error (also not JSON?!): %s %s' , r . status_code , r . text ) return if ( ( r . status_code == 503 ) and ( data [ 'errno' ] == 202 ) and ( _retry_count < max_retries ) ) : return _send_simple_push ( endpoint , version , max_retries , ( _retry_count + 1 ) ) else : logger . error ( 'SimplePush error: %s %s' , r . status_code , r . json ( ) )
hit a simple push endpoint to send a notification to a user .