Esempio n. 1
0
 def last(self, pk):
     """
     Get the last messageid
     """
     try:
         _ = int(pk)
     except (ValueError, TypeError):
         return Response(status=status.HTTP_400_BAD_REQUEST)
     return Response(MessageController.last_message_id(), status=status.HTTP_200_OK)
Esempio n. 2
0
 def last(self, pk):
     """
     Get the last messageid
     :param pk: Primary key of subscriber
     :type pk: int
     """
     try:
         _ = int(pk)
     except (ValueError, TypeError):
         return Response(status=status.HTTP_400_BAD_REQUEST)
     return Response(MessageController.last_message_id(), status=status.HTTP_200_OK)
Esempio n. 3
0
 def _wait(subscriber_id, message_id):
     messages = []
     last_message_id = 0
     counter = 0
     while len(messages) == 0:
         messages, last_message_id = MessageController.get_messages(subscriber_id, message_id)
         if len(messages) == 0:
             counter += 1
             if counter >= 120:  # 120 * 0.5 seconds = 60 seconds  = 1 minute
                 break
             gevent.sleep(.5)
     if len(messages) == 0:
         last_message_id = MessageController.last_message_id()
     MessageController.reset_subscriptions(subscriber_id)
     return messages, last_message_id