Ejemplo n.º 1
0
def pyres_scheduler():
    usage = "usage: %prog [options] arg1"
    parser = OptionParser(usage=usage)
    # parser.add_option("-q", dest="queue_list")
    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port", dest="port", type="int", default=6379)
    parser.add_option(
        "-l",
        "--log-level",
        dest="log_level",
        default="info",
        help='log level.  Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.',
    )
    parser.add_option(
        "-f",
        dest="logfile",
        help='If present, a logfile will be used.  "stderr", "stdout", and "syslog" are all special values.',
    )
    parser.add_option("-p", dest="pidfile", help="If present, a pidfile will be used.")
    (options, args) = parser.parse_args()
    log_level = getattr(logging, options.log_level.upper(), "INFO")
    # logging.basicConfig(level=log_level, format="%(module)s: %(asctime)s: %(levelname)s: %(message)s")
    setup_logging(procname="pyres_scheduler", log_level=log_level, filename=options.logfile)
    setup_pidfile(options.pidfile)
    server = "%s:%s" % (options.host, options.port)
    Scheduler.run(server)
Ejemplo n.º 2
0
def pyres_scheduler():
    usage = "usage: %prog [options] arg1"
    parser = OptionParser(usage=usage)
    #parser.add_option("-q", dest="queue_list")
    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port", dest="port", type="int", default=6379)
    parser.add_option(
        '-l',
        '--log-level',
        dest='log_level',
        default='info',
        help=
        'log level.  Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.'
    )
    parser.add_option(
        '-f',
        dest='logfile',
        help=
        'If present, a logfile will be used.  "stderr", "stdout", and "syslog" are all special values.'
    )
    parser.add_option('-p',
                      dest='pidfile',
                      help='If present, a pidfile will be used.')
    (options, args) = parser.parse_args()
    log_level = getattr(logging, options.log_level.upper(), 'INFO')
    #logging.basicConfig(level=log_level, format="%(module)s: %(asctime)s: %(levelname)s: %(message)s")
    setup_logging(procname="pyres_scheduler",
                  log_level=log_level,
                  filename=options.logfile)
    setup_pidfile(options.pidfile)
    server = '%s:%s' % (options.host, options.port)
    Scheduler.run(server)
Ejemplo n.º 3
0
def start_scheduler():
    logging.info("Starting scheduler for %s" % resq._REDIS)
    try:
        Scheduler.run(resq._REDIS)
        logging.info("started scheduler...")
    except Exception, e:
        logging.error("error starting scheduler: %s" % e)
Ejemplo n.º 4
0
def pyres_scheduler():
    usage = "usage: %prog [options] arg1"
    parser = OptionParser(usage=usage)
    #parser.add_option("-q", dest="queue_list")
    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port",dest="port",type="int", default=6379)
    parser.add_option('-l', '--log-level', dest='log_level', default='info', help='log level.  Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.')
    parser.add_option('-f', dest='logfile', help='If present, a logfile will be used.')
    (options,args) = parser.parse_args()
    log_level = getattr(logging, options.log_level.upper(),'INFO')
    #logging.basicConfig(level=log_level, format="%(module)s: %(asctime)s: %(levelname)s: %(message)s")
    setup_logging(log_level=log_level, filename=options.logfile)
    server = '%s:%s' % (options.host, options.port)
    Scheduler.run(server)
Ejemplo n.º 5
0
    def test_retries_give_up_eventually(self):
        now = datetime.datetime.utcnow()
        self.set_utcnow(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 60 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=60))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_utcnow(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it fails when we've been trying too long
        self.set_utcnow(now + datetime.timedelta(seconds=20))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 1
Ejemplo n.º 6
0
    def test_retry_on_exception(self):
        now = datetime.datetime.utcnow()
        self.set_utcnow(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 30 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=30))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_utcnow(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it runs fine when it's stopped crashing
        self.set_utcnow(now + datetime.timedelta(seconds=60))
        scheduler.handle_delayed_items()
        assert True == worker.process()
        assert worker.get_failed() == 0
Ejemplo n.º 7
0
    def test_retries_give_up_eventually(self):
        now = datetime.datetime.now()
        self.set_current_time(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 60 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=60))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_current_time(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it fails when we've been trying too long
        self.set_current_time(now + datetime.timedelta(seconds=20))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 1
Ejemplo n.º 8
0
    def test_retry_on_exception(self):
        now = datetime.datetime.now()
        self.set_current_time(now)
        worker = Worker(['basic'])
        scheduler = Scheduler()

        # queue up a job that will fail for 30 seconds
        self.resq.enqueue(RetryOnExceptionJob,
                now + datetime.timedelta(seconds=30))
        worker.process()
        assert worker.get_failed() == 0

        # check it retries the first time
        self.set_current_time(now + datetime.timedelta(seconds=5))
        scheduler.handle_delayed_items()
        assert None == worker.process()
        assert worker.get_failed() == 0

        # check it runs fine when it's stopped crashing
        self.set_current_time(now + datetime.timedelta(seconds=60))
        scheduler.handle_delayed_items()
        assert True == worker.process()
        assert worker.get_failed() == 0
Ejemplo n.º 9
0
 def test_schedule_shutdown(self):
     scheduler = Scheduler(self.resq)
     scheduler.schedule_shutdown(19,'')
     assert scheduler._shutdown
     
Ejemplo n.º 10
0
 def test_schedule_shutdown(self):
     scheduler = Scheduler(self.resq)
     scheduler.schedule_shutdown(19,'')
     assert scheduler._shutdown
Ejemplo n.º 11
0
 def test_scheduler_init(self):
     scheduler = Scheduler(self.resq)
     assert not scheduler._shutdown
     scheduler = Scheduler('localhost:6379')
     assert not scheduler._shutdown
     self.assertRaises(Exception, Scheduler, Basic)