コード例 #1
0
 def _schedule_poll(self, subscription_id):
     # If a poll is not already scheduled, run poll and schedule one.
     self.logger.debug('SCHED {}'.format(subscription_id))
     id = uuid.uuid1()
     self.logger.debug('{}'.format(id))
     with self._schedule_poll_lock:
         self.logger.debug('{}'.format(id))
         idx = self._subscription_id.get(subscription_id)
         if not self._poll_job[idx]:
             self.logger.debug(
                 "Scheduling poll job for {}"
                 .format(subscription_id)
             )
             spawn(self.poll(subscription_id))
             self._poll_job[idx] = Job(
                 self._scheduled_poll,
                 self.polling_interval(),
                 False,
                 subscription_id=subscription_id
             )
         else:
             self.logger.debug(
                 "Discarding poll job for {}"
                 .format(subscription_id)
             )
コード例 #2
0
 def on_post(self, req, rsp):
     t = time()
     self.logger.debug("Subscription handling POST: {} {}".format(req, t))
     body = req.get_body()
     for subscription in body:
         self.counter += 1
         subscription_id = subscription.get('subscription_id')
         if subscription_id:
             spawn(self._schedule_poll, int(subscription_id))