run schedule job

@param {Object} args argments
@api private
423446
function(args) {
	let service = args.service;
	let record = args.record;
	if (!service || !record || !record.module || !record.enable) {
		return;
	}

	if (service.master) {
		record.module.masterHandler(service.agent, null, function(err) {
			logger.error('interval push should not have a callback.');
		});
	} else {
		record.module.monitorHandler(service.agent, null, function(err) {
			logger.error('interval push should not have a callback.');
		});
	}
}
772391
function runCmd(cmd, args, fn) {
    args = args || [];
    let runner = require('child_process').spawn(cmd, args, {
        // keep color
        stdio: 'inherit',
    });
    runner.on('close', function(code) {
        if (fn) {
            fn(code);
        }
    });
}
567683
function run(commandLineArgs, callback) {
    if (commandLineArgs.help) {
        printUsage();
        callback(null);
        return;
    }

    if (commandLineArgs.version) {
        console.log(`Version: ${pjson.version}`);
        callback(null);
        return;
    }

    // Search for default config file if not specified
    if (!commandLineArgs.config) {
        try {
            fs.accessSync(path.join(process.cwd(), defaultConfigFile), fs.F_OK);
            commandLineArgs.config = defaultConfigFile;
        } catch (e) {
            // Default config file does not exist.
        }
    }

    if (!commandLineArgs.to && commandLineArgs.to !== 0) {
        commandLineArgs.to = 'max';
    }
    if (commandLineArgs.to !== 'max') {
        commandLineArgs.to = Number(commandLineArgs.to).toString();
    }

    let postgratorConfig;
    if (commandLineArgs.config) {
        const configFile = (path.isAbsolute(commandLineArgs.config))
            ? commandLineArgs.config
            : path.join(process.cwd(), commandLineArgs.config);

        try {
            fs.accessSync(configFile, fs.F_OK);
        } catch (e) {
            callback(new Error(`Config file not found: ${configFile}`));
            return;
        }
        postgratorConfig = require(configFile);
    } else {
        postgratorConfig = {
            migrationDirectory: commandLineArgs['migration-directory'],
            driver: commandLineArgs.driver,
            host: commandLineArgs.host,
            port: commandLineArgs.port,
            database: commandLineArgs.database,
            username: commandLineArgs.username,
            password: commandLineArgs.password,
            options: { encrypt: commandLineArgs.secure || false },
        };
    }
    if (!postgratorConfig.migrationDirectory) {
        postgratorConfig.migrationDirectory = commandLineOptions.DEFAULT_MIGRATION_DIRECTORY;
    }
    if (!path.isAbsolute(postgratorConfig.migrationDirectory)) {
        postgratorConfig.migrationDirectory = path.join(process.cwd(), postgratorConfig.migrationDirectory);
    }

    if (!fs.existsSync(postgratorConfig.migrationDirectory)) {
        if (!commandLineArgs.config && commandLineArgs['migration-directory'] === commandLineOptions.DEFAULT_MIGRATION_DIRECTORY) {
            printUsage();
        }
        callback(new Error(`Directory "${postgratorConfig.migrationDirectory}" does not exist.`));
        return;
    }

    const detectVersionConflicts = postgratorConfig['detect-version-conflicts'] || commandLineArgs['detect-version-conflicts'];
    delete postgratorConfig['detect-version-conflicts']; // It's not postgrator but postgrator-cli setting

    let postgrator;
    try {
        postgrator = new Postgrator(postgratorConfig);
    } catch (err) {
        printUsage();
        callback(err);
        return;
    }

    postgrator.on(
        'validation-started',
        migration => logMessage(`verifying checksum of migration ${migration.filename}`)
    );
    postgrator.on(
        'migration-started',
        migration => logMessage(`running ${migration.filename}`)
    );

    let databaseVersion = null;

    const migratePromise = postgrator.getMigrations()
        .then((migrations) => {
            if (!migrations || !migrations.length) {
                throw new Error(`No migration files found from "${postgratorConfig.migrationDirectory}"`);
            }
            if (detectVersionConflicts) {
                const conflictingMigrations = getConflictingMigrations(migrations);
                if (conflictingMigrations && conflictingMigrations.length > 0) {
                    const conflictingMigrationFileNames = getMigrationFileNames(conflictingMigrations);
                    const conflictingMigrationFileNamesString = conflictingMigrationFileNames.join('\n');
                    throw new Error(`Conflicting migration file versions:\n${conflictingMigrationFileNamesString}`);
                }
            }
        })
        .then(() => {
            return postgrator.getDatabaseVersion().catch(() => {
                logMessage('table schemaversion does not exist - creating it.');
                return 0;
            });
        })
        .then((version) => {
            databaseVersion = version;
            logMessage(`version of database is: ${version}`);
        })
        .then(() => {
            if (commandLineArgs.to === 'max') {
                return postgrator.getMaxVersion();
            }
            return commandLineArgs.to;
        })
        .then((version) => {
            logMessage(`migrating ${(version >= databaseVersion) ? 'up' : 'down'} to ${version}`);
        })
        .then(() => {
            return postgrator.migrate(commandLineArgs.to);
        });

    promiseToCallback(migratePromise, (err, migrations) => {
        // connection is closed, or will close in the case of SQL Server
        if (err && typeof err === 'string') {
            err = new Error(err);
        }
        return callback(err, migrations);
    });
}
356591
function queue(args) {
    args.push(resultsCallback);
    stack.push({caller: this.caller, args: args});
  }
1324725
def schedule(*args, &blk)
      return if blk.nil?
      @stop_mutex.synchronize do
        if @stopped
          GRPC.logger.warn('did not schedule job, already stopped')
          return
        end
        GRPC.logger.info('schedule another job')
        fail 'No worker threads available' if @ready_workers.empty?
        worker_queue = @ready_workers.pop

        fail 'worker already has a task waiting' unless worker_queue.empty?
        worker_queue << [blk, args]
      end
    end
1053462
public static void main(String args[])
    {
        Map<String,Object> properties = null;
        if (args != null)
        {
            properties = new Hashtable<String,Object>();
            Util.parseArgs(properties, args);
        }
        BaseApplication app = new MainApplication(null, properties, null);
        app.getTaskScheduler().addTask(new MessageReceivingPopClient());
    }
969591
def run(self, **kwargs):
        
        super().run(**kwargs)
        scheduler = self.scheduler_plugins[self.active_scheduler]()

        if not kwargs['no_daemon']:
            self.log.info('Starting {} worker with {} threads checking for new messages every {} seconds'.format(
                scheduler.name,
                kwargs['threads'],
                kwargs['delay']
            ))

            for i in range(kwargs['threads']):
                thd = threading.Thread(
                    target=self.execute_worker_thread,
                    args=(scheduler.execute_worker, kwargs['delay'])
                )
                thd.start()
        else:
            self.log.info('Starting {} worker for a single non-daemon execution'.format(
                scheduler.name
            ))
            scheduler.execute_worker()
190085
public static void main(String[] args) {
		StopwatchSample[] results = BenchmarkUtils.run(2, 5,
			new BenchmarkUtils.Task("enabled") {
				@Override
				public void perform() throws Exception {
					SimonManager.clear();
					SimonManager.enable();
					Stopwatch tested = SimonManager.getStopwatch("org.javasimon.stopwatch");
					for (int i = 0; i < LOOP; i++) {
						tested.start().stop();
					}
				}
			},
			new BenchmarkUtils.Task("disabled") {
				@Override
				public void perform() throws Exception {
					SimonManager.clear();
					SimonManager.enable();
					Stopwatch tested = SimonManager.getStopwatch("org.javasimon.stopwatch");
					tested.setState(SimonState.DISABLED, false);
					for (int i = 0; i < LOOP; i++) {
						tested.start().stop();
					}
				}
			},
			new BenchmarkUtils.Task("mgr-enabled") {
				@Override
				public void perform() throws Exception {
					SimonManager.clear();
					SimonManager.enable();
					for (int i = 0; i < LOOP; i++) {
						SimonManager.getStopwatch("org.javasimon.stopwatch").start().stop();
					}
				}
			},
			new BenchmarkUtils.Task("mgr-disabled") {
				@Override
				public void perform() throws Exception {
					SimonManager.clear();
					SimonManager.disable();
					for (int i = 0; i < LOOP; i++) {
						SimonManager.getStopwatch("org.javasimon.stopwatch").start().stop();
					}
				}
			},
			new BenchmarkUtils.Task("assign-ns") {
				@Override
				public void perform() throws Exception {
					for (int i = 0; i < LOOP; i++) {
						long ns = System.nanoTime();
					}
				}
			}
		);

		System.out.println("\nGoogle Chart avg:\n" +
			GoogleChartImageGenerator.barChart("10M-loop duration", results));
	}
1280310
function JobCallback (job) {
    if (job !== null) {
       job.gateway.Debug (6,"Queued Request:%s command=%s devid=%s [done]", job.request, job.command, job.devId);
    }
}
1275141
function run() {
        var startTime = (new Date()).getTime();

        // parse the command line using the commander object
        processCommandLine();

        // leverage the middleware to initialize all our services, adapters, etc. (i.e. connect to mongo, etc.)
        mwServiceInit.init({ container: 'batch' })
            .then(function () {
                var app = pancakes.cook(casing.camelCase(commander.app) + 'Batch');
                return app.run(commander);
            })
            .then(function () {
                var endTime = (new Date()).getTime();
                var diffTime = (endTime - startTime) / 1000;
                log.info(commander.app + ' complete (' + diffTime + 's)');
                process.exit(0);
            })
            .catch(function (err) {
                log.error(err);
                process.exit(1);
            });
    }
328553
def run(self, args):  # pylint: disable=unused-argument
        
        logging.basicConfig(stream=sys.stdout, level=logging.INFO)

        # This is used as a tool only to segment translation files when adding a
        # new segment.  In the regular workflow, the work is done by the extract
        # phase calling the functions above.
        locales = args.locale or []
        for locale in locales:
            segment_pofiles(self.configuration, locale)
729535
function run(argv, options, loader) {
  debug('argv', argv, 'options', options);

  if (options.help || options.h) {
    return loader.printUsage('env');
  }

  var selector = options._; // the argv, stripped of the flags (both -- and -)

  installPaths(function(er, paths) {
    var execPaths = resolvePaths(paths);

    execPaths['slc-npm'] = slcNpmPath(execPaths.slc);
    execPaths['node-npm'] = nodeNpmPath(execPaths.node);

    var env = {
      cwd: process.cwd(),
      paths: {
        link: paths,
        exec: execPaths
      },
      versions: process.versions,
      platform: process.platform,
      config: process.config,
      // redundant with .paths: execPath: process.execPath,
      features: process.features
    };
    try {
      env = selectProperties(selector, env);//XXX argv--> includes options?
    } catch (er) {
      return loader.error(er.message);
    }
    console.log(env);
  });
}
458396
private void evalDateTime(MessageArg arg) {
    if (!arg.resolve()) {
      return;
    }
    
    initCalendarArgsParser();
    parseArgs(calendarArgsParser);
    
    ZonedDateTime datetime = parseDateTime(arg);
    CalendarFormatter formatter = CLDR_INSTANCE.getCalendarFormatter(locale);
    formatter.format(datetime, calendarArgsParser.options(), buf);
  }
188588
function executeScheduleItem(schedule, iteration, value) {
  if (schedule.length < iteration + 1) {
    throw Error("ZLIQ: schedule for iteration " + iteration + " not defined");
  }
  let item = schedule[iteration];
  if (typeof item === "function") {
    return item(value);
  } else {
    return item;
  }
}
1347419
function run(keywordsToRun, keywordsDefined, passedArguments) {
        var vars = helpers.createLocalEnv(passedArguments);
        keywordsToRun = helpers.createKeywords(keywordsToRun);

        return {
            then: function(callback) {
                runKeywords(keywordsToRun, keywordsDefined, vars, callback);
            }
        };
    }
753422
public function runCommand($command, $argv) {
		if (!empty($this->args[0]) && $this->hasMethod($this->args[0])) {
			$this->action = $this->args[0];
		} else {
			$this->action = null;
		}
		$this->statisticsStart('AdvancedShell');
		Configure::write('debug', (int)Hash::get($this->params, 'debug'));
		if ($this->isScheduled()) {
			if ($this->params['scheduled-no-split']) {
				$this->setScheduleSplitter(new ScheduleNoSplit());
			}
			$this->schedule();
			$out = null;
		} elseif ($this->action) {
			$out = $this->{$this->action}();
		} else {
			$out = parent::runCommand($command, $argv);
		}
		$this->statisticsEnd('AdvancedShell');
		$this->sqlDump(false, false);
		$this->hr();
		return $out;
	}
119837
def apply_args(job, inputs, optional_inputs=None):
    
    _apply_args_loop(job, inputs, INPUT_FIELD)
    _apply_args_loop(job, optional_inputs, OPTIONAL_FIELD)
    return job