Process actions in the publishing schedule.

    Returns the number of actions processed.
761388
def process_actions(action_ids=None):
    
    actions_taken = 0
    action_list = PublishAction.objects.prefetch_related(
        'content_object',
    ).filter(
        scheduled_time__lte=timezone.now(),
    )

    if action_ids is not None:
        action_list = action_list.filter(id__in=action_ids)

    for action in action_list:
        action.process_action()
        action.delete()
        actions_taken += 1

    return actions_taken
1029368
def run(self, num_of_processes=multiprocessing.cpu_count()):
        

        # class + wordification on every example of the main table

        p = multiprocessing.Pool(num_of_processes)

        indices = chunks(list(range(len(self.target_table))), num_of_processes)  # )

        for ex_idxs in indices:
            self.resulting_documents.extend(wordify_examples(self.name_to_table, self.connecting_tables, self.context,
                                                             self.index_by_value, self.target_table.name,
                                                             self.word_att_length, ex_idxs))
        p.close()
        p.join()

        for i, ex in enumerate(self.target_table):
            self.resulting_classes.append(ex.get_class())
7810
def count(self, until=None):
        

        until = rationalize_until(until)
        return self.connection.zcount(self.scheduled_jobs_key, 0, until)
151141
public function process_url_actions() {
        if (!$this->page->user_is_editing()) {
            return false;
        }
        return $this->process_url_add() || $this->process_url_delete() ||
            $this->process_url_show_hide() || $this->process_url_edit() ||
            $this->process_url_move();
    }
1105071
def is_published(self):
        

        now = datetime.now()
        published = self.props.published
        if published:
            return published < now
        return False
158715
@Override
    public void run() {
        try {
            ScheduledEventQueue queue = ScheduledEventQueue.getSingleton();
            int batch_size = PropertyManager.getIntegerProperty(PropertyNames.SCHEDULED_EVENTS_BATCH_SIZE, 1000);
            int count = 0;
            Date now = new Date(DatabaseAccess.getCurrentTime());
            logger.log(LogLevel.TRACE, "Processing scheduled events at: " + now);
            ScheduledEvent event = queue.getNextReadyEvent(now);
            while (event!=null && count < batch_size) {
                count++;
                queue.processEvent(event, now);
                event = queue.getNextReadyEvent(now);
            }
        }
        catch (Throwable t) {
            logger.severeException(t.getMessage(), t);
        }
    }
953415
void processPendingReplications() {
    BlockInfo[] timedOutItems = pendingReplications.getTimedOutBlocks();
    if (timedOutItems != null) {
      writeLock();
      try {
        for (int i = 0; i < timedOutItems.length; i++) {
          NumberReplicas num = countNodes(timedOutItems[i]);
          neededReplications.add(
            timedOutItems[i], 
            num.liveReplicas(),
            num.decommissionedReplicas(),
            getReplication(timedOutItems[i]));
        }
      } finally {
        writeUnlock();
      }
      /* If we know the target datanodes where the replication timedout,
       * we could invoke decBlocksScheduled() on it. Its ok for now.
       */
    }
  }
533915
def _schedule_processing_blocks(self):
        """"""
        LOG.info('Starting to Schedule Processing Blocks.')
        while True:
            time.sleep(0.5)
            if not self._queue:
                continue
            if self._num_pbcs >= self._max_pbcs:
                LOG.warning('Resource limit reached!')
                continue
            _inspect = Inspect(app=APP)
            if self._queue and _inspect.active() is not None:
                next_pb = self._queue[-1]
                LOG.info('Considering %s for execution...', next_pb[2])
                utc_now = datetime.datetime.utcnow()
                time_in_queue = (utc_now -
                                 datetime_from_isoformat(next_pb[4]))
                if time_in_queue.total_seconds() >= 10:
                    item = self._queue.get()
                    LOG.info('------------------------------------')
                    LOG.info('>>> Executing %s! <<<', item)
                    LOG.info('------------------------------------')
                    execute_processing_block.delay(item)
                    self._num_pbcs += 1
                else:
                    LOG.info('Waiting for resources for %s', next_pb[2])
497220
def _process_queue(self):
        '''
        
        '''
        if len(self._queue):
            args, kwargs = self._queue.popleft()
            self.publish(*args, **kwargs)
128839
def handle_publish(self, package, _):
        '''
        
        '''
        try:
            self.publisher.publish(package)
            return package
        # Add an extra fallback in case a forked process leeks through
        except Exception:
            log.critical('Unexpected error while polling master events',
                         exc_info=True)
            return None
737139
def publish(self):
        

        try:
             for collection in self.settings.get("scheduler").get("collections"):
                yield self.publish_for_collection(collection)
        except Exception as ex:
            self.logger.error(ex)
17602
private void processCalendars()
   {
      List<Row> rows = getRows("calendar", null, null);
      m_reader.processCalendars(rows);
   }
1151839
def getPrinted(self):
        
        workflow = getToolByName(self, 'portal_workflow')
        review_state = workflow.getInfoFor(self, 'review_state', '')
        if review_state not in ['published']:
            return "0"
        report_list = sorted(self.objectValues('ARReport'),
                             key=lambda report: report.getDatePublished())
        if not report_list:
            return "0"
        last_report = report_list[-1]
        if last_report.getDatePrinted():
            return "1"
        else:
            for report in report_list:
                if report.getDatePrinted():
                    return "2"
        return "0"
248229
def _create_scheduled_actions(conn, as_name, scheduled_actions):
    '''
    
    '''
    if scheduled_actions:
        for name, action in six.iteritems(scheduled_actions):
            if 'start_time' in action and isinstance(action['start_time'], six.string_types):
                action['start_time'] = datetime.datetime.strptime(
                    action['start_time'], DATE_FORMAT
                )
            if 'end_time' in action and isinstance(action['end_time'], six.string_types):
                action['end_time'] = datetime.datetime.strptime(
                    action['end_time'], DATE_FORMAT
                )
            conn.create_scheduled_group_action(as_name, name,
                desired_capacity=action.get('desired_capacity'),
                min_size=action.get('min_size'),
                max_size=action.get('max_size'),
                start_time=action.get('start_time'),
                end_time=action.get('end_time'),
                recurrence=action.get('recurrence')
            )
795646
def _sorted_actions(self):
        
        for a in filter(lambda _: not _.last and \
                        not self.is_action(_, 'parsers'), self._actions):
            yield a
        for a in filter(lambda _: _.last and \
                        not self.is_action(_, 'parsers'), self._actions):
            yield a
        for a in filter(lambda _: self.is_action(_, 'parsers'),
                        self._actions):
            yield a
760937
def action_print(reader, *args):
    """"""
    arg_count = len(args)
    if arg_count == 0:
        stop_after = 0
    elif arg_count == 1:
        stop_after = int(args[0])
    else:
        raise RuntimeError("0 or 1 arguments expected for action 'print'")

    for i, record in enumerate(reader, 1):
        print(record.to_message())
        if i == stop_after:
            break
666375
def num_pending_tasks(self):
        
        return len(self._status_tasks[PENDING]) + len(self._status_tasks[RUNNING])