def post(self):
     """POST handler for updating a counter which is specified in payload."""
     counter = self.request.get("counter")
     if counter == "simple":
         simple_counter.increment()
     else:
         general_counter.increment(DEFAULT_COUNTER_NAME)
     self.redirect("/")
 def post(self):
     """POST handler for updating a counter which is specified in payload."""
     counter = self.request.get('counter')
     if counter == 'simple':
         simple_counter.increment()
     else:
         general_counter.increment(DEFAULT_COUNTER_NAME)
     self.redirect('/')
Beispiel #3
0
    def run(self, schedule, content, recipient_queues, sharding_count_name):
        futures = []
        for recipient in json.loads(recipient_queues.data):
            message = Mail()
            message.set_subject(schedule.subject)
            message.set_html(
                replace_edm_csv_property(content, recipient,
                                         schedule.replace_edm_csv_property))
            message.set_from('%s <%s>' %
                             (schedule.sender_name, schedule.sender_email))
            if schedule.reply_to:
                message.set_replyto(schedule.reply_to)
            message.add_to(recipient.get('email'))
            message.add_category(schedule.category)

            status, msg = self._send(message, schedule.is_dry_run,
                                     schedule.dry_run_fail_rate)
            futures.append(dict(recipient=recipient, status=status, msg=msg))

        send_success = filter(lambda f: f.get('status') == 200, futures)
        send_fail = filter(lambda f: f.get('status') != 200, futures)

        # save success send log
        if send_success:
            self.to_put.extend(
                self.success_log(schedule, send_success, self.sender))

        # save fail send log
        if send_fail:
            self.to_put.extend(
                self.fail_log(schedule, send_fail, self.sender, content))

        recipient_queues.status = 'executed'
        self.to_put.append(recipient_queues)

        if self.to_put:
            ndb.put_multi(self.to_put)
            self.to_put = []

        general_counter.increment(sharding_count_name)
Beispiel #4
0
 def _post_put_hook(self, future):
     # logging.info("_post_put_hook: " + str(future.get_result()))
     general_counter.increment(self.__class__.__name__)
     memcache.flush_all()