def _incrdecr_async(self, key, is_negative, delta, namespace=None,
                initial_value=None, rpc=None):
    """Async version of _incrdecr().

    Returns:
      A UserRPC instance whose get_result() method returns the same
      kind of value as _incrdecr() returns.
    """
    if not isinstance(delta, (int, long)):
      raise TypeError('Delta must be an integer or long, received %r' % delta)
    if delta < 0:
      raise ValueError('Delta must not be negative.')


    if not isinstance(key, basestring):
      try:
        it = iter(key)
      except __HOLE__:

        pass
      else:
        if is_negative:
          delta = -delta
        return self.offset_multi_async(dict((k, delta) for k in it),
                                       namespace=namespace,
                                       initial_value=initial_value,
                                       rpc=rpc)


    request = MemcacheIncrementRequest()
    self._add_app_id(request)
    _add_name_space(request, namespace)
    response = MemcacheIncrementResponse()
    request.set_key(_key_string(key))
    request.set_delta(delta)
    if is_negative:
      request.set_direction(MemcacheIncrementRequest.DECREMENT)
    else:
      request.set_direction(MemcacheIncrementRequest.INCREMENT)
    if initial_value is not None:

      request.set_initial_value(long(initial_value))
      initial_flags = None
      if isinstance(initial_value, int):
        initial_flags = TYPE_INT
      elif isinstance(initial_value, long):
        initial_flags = TYPE_LONG
      if initial_flags is not None:
        request.set_initial_flags(initial_flags)


    return self._make_async_call(rpc, 'Increment', request, response,
                                 self.__incrdecr_hook, None)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/memcache/__init__.py/Client._incrdecr_async