Deliver pending EmailSpool records.
434052
public function spool($limit = 10)
    {
        $done = 0;
        // find all the spooled emails
        $emailSpools = EmailSpool::model()->findAll(array(
            'condition' => 't.status=:status',
            'params' => array(':status' => 'pending'),
            'order' => 't.priority DESC, t.created ASC',
            'limit' => $limit,
        ));
        foreach ($emailSpools as $emailSpool) {

            // update status to processing
            $emailSpool->status = 'processing';
            $emailSpool->save(false);

            // build the message
            $swiftMessage = $emailSpool->unpack($emailSpool->message);

            // send the email
            $sent = $this->deliver($swiftMessage, $emailSpool->transport);

            // update status and save
            $emailSpool->status = $sent ? 'emailed' : 'error';
            $emailSpool->sent = time();
            $emailSpool->save(false);
            $done++;
        }
        return $done;
    }
1212312
def deliver!(mail)
      check_delivery_params(mail) if respond_to?(:check_delivery_params)

      clean_up

      basepath = File.join(settings[:location], Time.now.to_i.to_s)

      save_email(mail, basepath)

      return true unless mail.attachments.any?

      add_attachments(mail, basepath)
    end
998042
def pending():
    """"""

    signalbus = current_app.extensions['signalbus']
    pending = []
    total_pending = 0
    for signal_model in signalbus.get_signal_models():
        count = signal_model.query.count()
        if count > 0:
            pending.append((count, signal_model.__name__))
        total_pending += count
    if pending:
        pending.sort()
        max_chars = len(str(pending[-1][0]))
        for n, signal_name in pending:
            click.echo('{} of type "{}"'.format(str(n).rjust(max_chars), signal_name))
    click.echo(25 * '-')
    click.echo('Total pending: {} '.format(total_pending))
803705
def pending
      v = RRRSpec.redis.hget(key, 'pending')
      v.present? ? v.to_i : nil
    end
120277
protected void requestingAccessToPool() {
        /*
         * Added for holding out connection request while
         * a free or shared pool is being updated
         */
        if (updateToPoolInProgress) {
            synchronized (updateToPoolInProgressLockObject) {
                while (updateToPoolInProgress) {
                    try {
                        /*
                         * Wait for 250 milliseconds and check if update to pool is
                         * finished. The update is complete when updateToPoolInProgress is
                         * changed to false and a updateToPoolInProgressLockObject.notifyAll()
                         * is called.
                         */
                        updateToPoolInProgressLockObject.wait(updateToPoolInProgressSleepTime);
                    } catch (InterruptedException e1) {
                        // We don't need to do anything here.
                        // e1.printStackTrace();
                    }
                }
            }
        }
        activeRequest.incrementAndGet();
        if (updateToPoolInProgress) {
            activeRequest.decrementAndGet();
            synchronized (updateToPoolInProgressLockObject) {
                while (updateToPoolInProgress) {
                    try {
                        /*
                         * Wait for 250 milliseconds and check if update to pool is
                         * finished. The update is complete when updateToPoolInProgress is
                         * changed to false and a updateToPoolInProgressLockObject.notifyAll()
                         * is called.
                         */
                        updateToPoolInProgressLockObject.wait(updateToPoolInProgressSleepTime);
                    } catch (InterruptedException e1) {
                        // We don't need to do anything here.
                        // e1.printStackTrace();
                    }
                }
            }
            activeRequest.incrementAndGet();
        }
    }
295120
def deliver_later!
      ActionMessenger::MessageDeliveryJob.perform_later(self.class.name, 'deliver_now!', messenger_class.to_s, method_name.to_s, *args)
    end
870965
def emails(self, qs):
        
        self.stdout.write(",\n".join(ent['email'] for ent in qs))
        self.stdout.write("\n")
868555
def deliver!(mail)
      unless settings[:append_emails] == false
        original_emails = email_list(mail)
      end

      %w{ to cc bcc }.each do |field|
        mail.send(:"#{field}=", filter_emails(mail.send(field)))
      end

      unless settings[:append_emails] == false
        new_emails = original_emails - email_list(mail)
        if !new_emails.empty?
          mail.body = "#{mail.body}\n\nExtracted Recipients: #{new_emails.join(', ')}"
        end
      end

      if settings[:subject_prefix]
        mail.subject = settings[:subject_prefix] + mail.subject
      end

      @delivery_method.deliver!(mail) unless mail.to.blank?

      mail
    end
31292
def _get_pages(self, locations, req):
        """"""
        pending_queue = Queue()
        for location in locations:
            pending_queue.put(location)
        done = []
        seen = set()
        threads = []
        for i in range(min(10, len(locations))):
            t = threading.Thread(target=self._get_queued_page, args=(req, pending_queue, done, seen))
            t.setDaemon(True)
            threads.append(t)
            t.start()
        for t in threads:
            t.join()
        return done
130787
function sendQueue() {

	var subject = ['Anomaly Report']
	if (!opts.noSubjectApp && opts.app) subject.push(opts.app)
	if (!opts.noSubjectHost) subject.push(os.hostname())
	subject = subject.join(' ')

	var body
	if (skipCounter > 0) { // notify of skipped emails
		enqueuedEmails.push('Skipped:' + skipCounter)
		skipCounter = 0
	}
	body = enqueuedEmails.join('\n\n')
	enqueuedEmails = []

	emailer.send({subject: subject, body: body}) // TODO error handling when haraldops and emailer updated
	lastSent = Date.now()
	startSilentPeriod()
}
732874
def subpool_imap(pool_size, func, iterable, flatten=False, unordered=False, buffer_size=None):
  

  from .context import get_current_job, set_current_job, log

  if not pool_size:
    for args in iterable:
      yield func(*args)

  counter = itertools_count()

  current_job = get_current_job()

  def inner_func(*args):
    """ As each call to 'func' will be done in a random greenlet of the subpool, we need to
        register their IDs with set_current_job() to make get_current_job() calls work properly
        inside 'func'.
    """
    next(counter)
    if current_job:
      set_current_job(current_job)

    try:
      ret = func(*args)
    except Exception as exc:
      trace = traceback.format_exc()
      exc.subpool_traceback = trace
      raise

    if current_job:
      set_current_job(None)
    return ret

  def inner_iterable():
    """ This will be called inside the pool's main greenlet, which ID also needs to be registered """
    if current_job:
      set_current_job(current_job)

    for x in iterable:
      yield x

    if current_job:
      set_current_job(None)

  start_time = time.time()
  pool = gevent.pool.Pool(size=pool_size)

  if unordered:
    iterator = pool.imap_unordered(inner_func, inner_iterable(), maxsize=buffer_size or pool_size)
  else:
    iterator = pool.imap(inner_func, inner_iterable())

  for x in iterator:
    if flatten:
      for y in x:
        yield y
    else:
      yield x

  pool.join(raise_error=True)
  total_time = time.time() - start_time

  log.debug("SubPool ran %s greenlets in %0.6fs" % (counter, total_time))
3675
def pending_confirmations(self):
        
        return sorted([(idx, msg)
                       for idx, msg in enumerate(self.published_messages)
                       if not msg.future.done()],
                      key=lambda x: x[1].delivery_tag)
883068
def create_outbound_email(self, subject, description, email, email_config_id, **kwargs):
        """"""
        url = 'tickets/outbound_email'
        priority = kwargs.get('priority', 1)
        data = {
            'subject': subject,
            'description': description,
            'priority': priority,
            'email': email,
            'email_config_id': email_config_id,
        }
        data.update(kwargs)
        ticket = self._api._post(url, data=json.dumps(data))
        return Ticket(**ticket)
673580
private void sendPending() {
    while (outstanding.get() < concurrency) {
      final TopicQueue queue = pendingTopics.poll();
      if (queue == null) {
        return;
      }

      queue.pending = false;
      final int sent = queue.sendBatch();

      // Did we send a whole batch? Then there might be more messages in the queue. Mark as pending again.
      if (sent == batchSize) {
        queue.pending = true;
        pendingTopics.offer(queue);
      }
    }
  }
318681
def process_delivery(message, notification):
    """"""
    mail = message['mail']
    delivery = message['delivery']

    if 'timestamp' in delivery:
        delivered_datetime = clean_time(delivery['timestamp'])
    else:
        delivered_datetime = None

    deliveries = []
    for eachrecipient in delivery['recipients']:
        # Create each delivery 
        deliveries += [Delivery.objects.create(
            sns_topic=notification['TopicArn'],
            sns_messageid=notification['MessageId'],
            mail_timestamp=clean_time(mail['timestamp']),
            mail_id=mail['messageId'],
            mail_from=mail['source'],
            address=eachrecipient,
            # delivery
            delivered_time=delivered_datetime,
            processing_time=int(delivery['processingTimeMillis']),
            smtp_response=delivery['smtpResponse']
        )]

    # Send signals for each delivery.
    for eachdelivery in deliveries:
        signals.feedback.send(
            sender=Delivery,
            instance=eachdelivery,
            message=message,
            notification=notification
        )

    logger.info('Logged %s Deliveries(s)', str(len(deliveries)))

    return HttpResponse('Delivery Processed')
1261194
def scheduled(self, offset=0, count=25):
        ''''''
        return self.client('jobs', 'scheduled', self.name, offset, count)
857088
def deliver_slice(schedule):
    
    if schedule.email_format == SliceEmailReportFormat.data:
        email = _get_slice_data(schedule)
    elif schedule.email_format == SliceEmailReportFormat.visualization:
        email = _get_slice_visualization(schedule)
    else:
        raise RuntimeError('Unknown email report format')

    subject = __(
        '%(prefix)s %(title)s',
        prefix=config.get('EMAIL_REPORTS_SUBJECT_PREFIX'),
        title=schedule.slice.slice_name,
    )

    _deliver_email(schedule, subject, email)