Print the UI that allows us to change the number of tasks assigned per
heartbeat.
9875
private void showNumTaskPerHeartBeatOption(
          PrintWriter out, boolean advancedView) {

    out.print("<h2>Number of Assigned Tasks Per HeartBeat</h2>\n");
    out.printf("<p>Number of map tasks assigned per heartbeat:%s",
                generateSelect(Arrays.asList("1,2,3,4,5,6,7,8,9,10".split(",")),
                               scheduler.getMapPerHeartBeat() + "",
                               "/fairscheduler?setMapPerHeartBeat=<CHOICE>" +
                               (advancedView ? "&advanced" : "")));

    out.printf("<p>Number of reduce tasks assigned per heartbeat:%s",
               generateSelect(Arrays.asList("1,2,3,4,5,6,7,8,9,10".split(",")),
                              scheduler.getReducePerHeartBeat() + "",
                              "/fairscheduler?setReducePerHeartBeat=<CHOICE>" +
                              (advancedView ? "&advanced" : "")));
  }
62002
public synchronized void printStatistics() {
        // quickly memoize and update counters, get the time, record update time, etc...
        long nowSuccesses = incrementCount.get();
        long nowFailures = failureCount.get();
        long prevSuccesss = lastPeriod.getAndSet(nowSuccesses);
        long endTime = System.currentTimeMillis();
        long startTime = lastStatsReportTS;
        lastStatsReportTS = endTime;

        // do math with as much safety as possible
        long invocationsCompleted = Math.max(nowSuccesses - prevSuccesss, 0);
        long periodDurationMs = Math.max(endTime - startTime, 1);
        long cumulativeDurationMs = Math.max(endTime - benchmarkStartTS, 1);
        long periodThroughput = (long) (invocationsCompleted / (periodDurationMs / 1000.0));
        long cumulativeThroughput = (long) (nowSuccesses / (cumulativeDurationMs / 1000.0));
        long time = (long) (Math.round(endTime - benchmarkStartTS) / 1000.0);

        // print out periodic report
        System.out.printf("%02d:%02d:%02d ", time / 3600, (time / 60) % 60, time % 60);
        System.out.printf("Period Throughput %10d/s, ", periodThroughput);
        System.out.printf("Cumulative Throughput %10d/s, ", cumulativeThroughput);
        System.out.printf("Total Failures %10d", nowFailures);
        System.out.printf("\n");
    }
224627
def handle_heartbeat(queue_name):
    """"""
    task_id = request.form.get('task_id', type=str)
    message = request.form.get('message', type=str)
    index = request.form.get('index', type=int)
    try:
        work_queue.heartbeat(
            queue_name,
            task_id,
            request.form.get('owner', request.remote_addr, type=str),
            message,
            index)
    except work_queue.Error, e:
        return utils.jsonify_error(e)

    db.session.commit()
    logging.debug('Task heartbeat: queue=%r, task_id=%r, message=%r, index=%d',
                  queue_name, task_id, message, index)
    return flask.jsonify(success=True)
608686
def task(ft):
	
	ft.pack(expand = True,  fill = BOTH,  side = TOP)
	pb_hD = ttk.Progressbar(ft, orient = 'horizontal', mode = 'indeterminate')
	pb_hD.pack(expand = True, fill = BOTH, side = TOP)
	pb_hD.start(50)
	ft.mainloop()
1082178
def _subtask_result(self, idx, value):
        """"""
        self._results[idx] = value
        if len(self._results) == self._num_tasks:
            self.set_result([
                self._results[i]
                for i in range(self._num_tasks)
            ])
616249
def stats_printer(stats_queue):
  """"""
  proc_stats = [ProcessStats(i) for i in range(FLAGS.parallel)]
  print_time = start_time = time.time()
  width = 107

  running = True
  while running:
    print_time += 10

    while time.time() < print_time:
      try:
        s = stats_queue.get(True, print_time - time.time())
        if s is None:  # Signal to print and exit NOW!
          running = False
          break
        proc_stats[s.proc_id] = s
      except queue.Empty:
        pass

    replay_stats = ReplayStats()
    for s in proc_stats:
      replay_stats.merge(s.replay_stats)

    print((" Summary %0d secs " % (print_time - start_time)).center(width, "="))
    print(replay_stats)
    print(" Process stats ".center(width, "-"))
    print("\n".join(str(s) for s in proc_stats))
    print("=" * width)
182655
def populate_display_n(self):
        
        cb = self.get_widget('display_n')
        screen = self.get_widget('config-window').get_screen()

        cb.append_text("always on primary")

        for m in range(0, int(screen.get_n_monitors())):
            if m == int(screen.get_primary_monitor()):
                # TODO l10n
                cb.append_text(str(m) + ' ' + '(primary)')
            else:
                cb.append_text(str(m))
442117
def configure(self, config):
        
        self.config = config
        self.update_monitors()

        # initialize thread pools
        for profile in ('worker', 'result'):
            for _ in range(config['threads'][profile]['number']):
                worker = threading.Thread(target=config['threads'][profile]['function'])
                worker.daemon = True
                worker.start()

        # send a heartbeat right away
        self.heartbeat()

        # setup interval jobs
        self.refresh_stopper = set_interval(config['interval']['refresh']*1000,
                                            self.update_monitors)
        self.heartbeat_stopper = set_interval(config['interval']['heartbeat']*1000,
                                              self.heartbeat)
        self.reporting_stopper = set_interval(config['interval']['reporting']*1000,
                                              self.reporting)

        return self
638407
synchronized void setHealthStatus(TaskTrackerHealthStatus healthStatus) {
    healthStatus.setNodeHealthy(this.isHealthy());
    healthStatus.setHealthReport(this.getHealthReport());
    healthStatus.setLastReported(this.getLastReportedTime());
  }
1209244
protected void schedulePeriodicStats() {
        m_timer = new Timer();
        TimerTask statsPrinting = new TimerTask() {
            @Override
            public void run() { printStatistics(); }
        };
        m_timer.scheduleAtFixedRate(statsPrinting,
                m_config.displayinterval * 1000,
                m_config.displayinterval * 1000);
    }
1274236
function startInterval() {
    if (intervalId !== null) {
        return;
    }
    intervalId = setInterval(function () {
        if (remainedTasks.length && currentCount < limitCount) {
            var task = remainedTasks.shift();
            currentCount++;
            if (monitorCallback) {
                monitorCallback("start", remainedTasks);
            }
            var process = originalSpawn.apply(null, task[0]);
            process.on("close", function (code) {
                if (monitorCallback) {
                    monitorCallback("close", remainedTasks, code);
                }
                currentCount--;
                if (currentCount === 0 && remainedTasks.length === 0) {
                    callWaitAllCallbacks();
                }
            });
            var callback = remainedTaskCallbacks[task[1]];
            delete remainedTaskCallbacks[task[1]];
            if (callback) {
                callback(process);
            }
        }
    }, 20);
}
451658
public function change() {
		$table = $this->table('queued_tasks');

		$table->changeColumn('status', 'string', [
		    'length' => 255,
			'null' => true,
			'default' => null,
		]);

		$table->save();
	}
814417
def _heartbeat(self, queue, task_ids):
        
        now = time.time()
        self.connection.zadd(self._key(ACTIVE, queue),
                             **{task_id: now for task_id in task_ids})
1216795
def on_display_n_changed(self, combo):
        

        i = combo.get_active_iter()
        if not i:
            return

        model = combo.get_model()
        first_item_path = model.get_path(model.get_iter_first())

        if model.get_path(i) == first_item_path:
            val_int = ALWAYS_ON_PRIMARY
        else:
            val = model.get_value(i, 0)
            val_int = int(val.split()[0])  # extracts 1 from '1' or from '1 (primary)'
        self.settings.general.set_int('display-n', val_int)
402504
def for_display(self):
        
        skip = ""
        if self.skip:
            skip = " [SKIP]"
        result = "{step_num}: {path}{skip}".format(
            step_num=self.step_num, path=self.path, skip=skip
        )
        description = self.task_config.get("description")
        if description:
            result += ": {}".format(description)
        return result
607206
def do_workers(self, args):
        ''''''
        workers = self.task_master.workers(alive=not args.all)
        for k in sorted(workers.iterkeys()):
            self.stdout.write('{0} ({1})\n'.format(k, workers[k]))
            if args.details:
                heartbeat = self.task_master.get_heartbeat(k)
                for hk, hv in heartbeat.iteritems():
                    self.stdout.write('  {0}: {1}\n'.format(hk, hv))
1274538
public static function tick()
    {
        if (empty(self::$_tasks)) {
            pcntl_alarm(0);
            return;
        }

        $time_now = time();
        foreach (self::$_tasks as $run_time => $task_data) {
            if ($time_now >= $run_time) {
                foreach ($task_data as $index => $one_task) {
                    $task_func     = $one_task[0];
                    $task_args     = $one_task[1];
                    $persistent    = $one_task[2];
                    $time_interval = $one_task[3];
                    try {
                        call_user_func_array($task_func, $task_args);
                    } catch (\Exception $e) {
                        echo $e;
                    }
                    if ($persistent) {
                        self::add($time_interval, $task_func, $task_args);
                    }
                }
                unset(self::$_tasks[$run_time]);
            }
        }
    }