Service at most `limit` number of messages from the view_changer's outBox.

        :return: the number of messages successfully serviced.
772916
async def serviceViewChangerInbox(self, limit: int = None) -> int:
        
        msgCount = 0
        while self.msgsToViewChanger and (not limit or msgCount < limit):
            msgCount += 1
            msg = self.msgsToViewChanger.popleft()
            self.view_changer.inBox.append(msg)
        await self.view_changer.serviceQueues(limit)
        return msgCount
377869
def is_outbound_message_filter(cb):
    

    try:
        handlers = get_magic_attr(cb)
    except AttributeError:
        return False

    hs = HandlerSpec(
        (_apply_outbound_message_filter, ())
    )

    return hs in handlers
45816
def consume(self, limit=None):
        """"""
        for total_message_count in count():
            if limit and total_message_count >= limit:
                raise StopIteration
            self.drain_events()
            yield True
1068601
def handleAllSync(self, deq: deque, limit=None) -> int:
        
        count = 0
        while deq and (not limit or count < limit):
            count += 1
            msg = deq.popleft()
            self.handleSync(msg)
        return count
877606
def size_limit(self):
        
        limits = [
            lim for lim in current_files_rest.file_size_limiters(
                self)
            if lim.limit is not None
        ]
        return min(limits) if limits else None
1245205
async def message_throttled(self, message: types.Message, throttled: Throttled):
        
        handler = current_handler.get()
        dispatcher = Dispatcher.get_current()
        if handler:
            key = getattr(handler, 'throttling_key', f"{self.prefix}_{handler.__name__}")
        else:
            key = f"{self.prefix}_message"

        # Calculate how many time is left till the block ends
        delta = throttled.rate - throttled.delta

        # Prevent flooding
        if throttled.exceeded_count <= 2:
            await message.reply('Too many requests! ')

        # Sleep.
        await asyncio.sleep(delta)

        # Check lock status
        thr = await dispatcher.check_key(key)

        # If current message is not last with current key - do not send message
        if thr.exceeded_count == throttled.exceeded_count:
            await message.reply('Unlocked.')
413686
async def service_observable(self, limit) -> int:
        
        if not self.isReady():
            return 0
        o = self._service_observable_out_box(limit)
        i = await self._observable.serviceQueues(limit)
        return o + i
1223841
def send_messages(self, messages):
		""""""
		msg_count = 0
		for message in messages:  # .message() triggers header validation
			message.message()
			msg_count += 1
		mail.outbox.extend(messages)
		return msg_count
780902
function truncateMessage (message) {
  var MAX_SIZE = 256;

  return message && message.length > MAX_SIZE
    ? message.substring(0, MAX_SIZE)
    : message;
}
989056
async def broadcaster() -> int:
    
    count = 0
    try:
        for user_id in get_users():
            if await send_message(user_id, '<b>Hello!</b>'):
                count += 1
            await asyncio.sleep(.05)  # 20 messages per second (Limit: 30 messages per second)
    finally:
        log.info(f"{count} messages successful sent.")

    return count
1101091
def clear(self, page_size=10, vtimeout=10):
        """"""
        n = 0
        l = self.get_messages(page_size, vtimeout)
        while l:
            for m in l:
                self.delete_message(m)
                n += 1
            l = self.get_messages(page_size, vtimeout)
        return n
640219
def frame_message(self):
        
        if self._frame is not None:
            self.discard_message()
        panes = []
        p = origin = self._origin
        extent = self._extent
        while p < extent:
            available = extent - p
            if available < 2:
                break
            chunk_size, = struct_unpack(">H", self._view[p:(p + 2)])
            p += 2
            if chunk_size == 0:
                self._limit = p
                self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes)
                return True
            q = p + chunk_size
            panes.append((p - origin, q - origin))
            p = q
        return False
106065
def outbox(request, template_name='django_messages/outbox.html'):
    
    message_list = Message.objects.outbox_for(request.user)
    return render(request, template_name, {
        'message_list': message_list,
    })
1223543
def consume_messages(self, batchsize):
        
        if not self._reservoir:
            self.finished = True
            return
        for msg in self._reservoir[:batchsize]:
            yield msg
        self._reservoir = self._reservoir[batchsize:]
1209859
async def service(self, limit=None, quota: Optional[Quota] = None) -> int:
        
        if self.listener:
            await self._serviceStack(self.age, quota)
        else:
            logger.info("{} is stopped".format(self))

        r = len(self.rxMsgs)
        if r > 0:
            pracLimit = limit if limit else sys.maxsize
            return self.processReceived(pracLimit)
        return 0
1347203
def limit_roles(self):
        
        new_roles = {}
        roles = self.options.limit.split(",")

        for key, value in self.roles.iteritems():
            for role in roles:
                role = role.strip()
                if key == role:
                    new_roles[key] = value

        self.roles = new_roles
753452
def limit(self, limit):
        
        query = self._copy()
        query._limit = limit
        return query