'in enhanced mode, send_notification may return error response from APNs if any'

def send_notification(self, token_hex, payload, identifier=0, expiry=0):

    if self.enhanced:
        self._last_activity_time = time.time()
        message = self._get_enhanced_notification(token_hex, payload, identifier, expiry)
        for i in range(WRITE_RETRY):
            try:
                with self._send_lock:
                    self._make_sure_error_response_handler_worker_alive()
                    self.write(message)
                    self._sent_notifications.append(dict({'id': identifier, 'message': message}))
                break
            except socket_error as e:
                delay = (10 + (i * 2))
                _logger.exception((((((((((('sending    notification    with    id:' + str(identifier)) + '    to    APNS    failed:    ') + str(type(e))) + ':    ') + str(e)) + '    in    ') + str((i + 1))) + 'th    attempt,    will    wait    ') + str(delay)) + '    secs    for    next    action'))
                time.sleep(delay)
    else:
        self.write(self._get_notification(token_hex, payload))
