当前位置: 首页>>代码示例>>Python>>正文


Python scheduler.Client类代码示例

本文整理汇总了Python中indico.modules.scheduler.Client的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _stop

def _stop(args):

    _setup(args)

    running = _check_running()

    if not args.force and not running:
        raise Exception("The daemon doesn't seem to be running (consider -f?)")

    dbi = DBMgr.getInstance()
    dbi.startRequest()
    c = Client()
    c.shutdown(msg="Daemon script")
    dbi.commit()

    print "Waiting for death confirmation... "
    for i in range(0, 20):
        if not c.getStatus()['state']:
            break
        else:
            time.sleep(1)
            dbi.sync()
    else:
        print "FAILED!"

    print "DONE!"
    dbi.endRequest()
开发者ID:NIIF,项目名称:indico,代码行数:27,代码来源:daemon_script.py

示例2: testTaskRelocate

    def testTaskRelocate(self):
        """
        Creating 1 task and relocating it
        """

        self._startSomeWorkers([TestTask],
                               [base.TimeSource.get().getCurrentTime() + \
                                timedelta(seconds=2)])

        base.TimeSource.get().sleep(1)

        with self._context('database', sync=True) as conn:

            # wait to task to be scheduled
            c = Client()
            while True:
                try:
                    conn.sync()
                    t = c.getTask(0)
                    break
                except KeyError:
                    continue

            c.moveTask(t, base.TimeSource.get().getCurrentTime() + timedelta(seconds=2))

        self.assertEqual(self._checkWorkersFinished(5),
                         True)

        self._assertStatus({'state': True,
                            'waiting': 0,
                            'running': 0,
                            'spooled': 0,
                            'finished': 1,
                            'failed': 0})
开发者ID:VishrutMehta,项目名称:indico,代码行数:34,代码来源:server_test.py

示例3: addOccurrenceNotificationsTask

def addOccurrenceNotificationsTask(dbi, prevVersion):
    """
    Add OccurrenceNotificationsTask to scheduler and remove old RoomReservationTask
    """
    scheduler_client = Client()
    scheduler_module = scheduler_client._schedMod
    old_tasks = []

    for _, task in scheduler_module.getWaitingQueue():
        if getattr(task, 'typeId', None) in {'RoomReservationTask', 'RoomReservationEndTask'}:
            old_tasks.append(task)
    for task in scheduler_module._runningList:
        if getattr(task, 'typeId', None) in {'RoomReservationTask', 'RoomReservationEndTask'}:
            old_tasks.append(task)
    for finished_task in scheduler_module._finishedIndex.values():
        task = finished_task._task if hasattr(finished_task, '_task') else finished_task
        if getattr(task, 'typeId', None) in {'RoomReservationTask', 'RoomReservationEndTask'}:
            scheduler_module._finishedIndex.unindex_obj(finished_task)
    for failed_task in scheduler_module._failedIndex.values():
        task = failed_task._task if hasattr(failed_task, '_task') else failed_task
        if getattr(task, 'typeId', None) in {'RoomReservationTask', 'RoomReservationEndTask'}:
            scheduler_module._failedIndex.unindex_obj(failed_task)
    for task in old_tasks:
        scheduler_client.dequeue(task)

    scheduler_client.enqueue(OccurrenceNotifications(rrule.HOURLY, byminute=0, bysecond=0))
    dbi.commit()
开发者ID:marcosmolla,项目名称:indico,代码行数:27,代码来源:migrate.py

示例4: _shutdown

    def _shutdown(self):

        with self._context('database', sync=True):
            c = Client()
            c.shutdown()

        self._sched.join()
开发者ID:VishrutMehta,项目名称:indico,代码行数:7,代码来源:server_test.py

示例5: _show

def _show(args):

    dbi = DBMgr.getInstance()

    dbi.startRequest()
    c = Client()

    if args.field == "status":
        status = c.getStatus()

        print "Scheduler is currently %s" % \
              ("running" if status['state'] else "NOT running")
        print """
Spooled commands: %(spooled)s

Tasks:
  - Waiting:  %(waiting)s
  - Running:  %(running)s
  - Failed:   %(failed)s
  - Finished: %(finished)s
""" % status
    elif args.field == "spool":

        for op, obj in c.getSpool():
            if op in ['add', 'del']:
                print "%s %s" % (op, obj)
            else:
                print op

    dbi.endRequest()
开发者ID:ferhatelmas,项目名称:indico,代码行数:30,代码来源:daemon_script.py

示例6: _show

def _show(args):

    dbi = DBMgr.getInstance()

    dbi.startRequest()
    c = Client()

    if args.field == "status":
        status = c.getStatus()

        if status['state']:
            print 'Scheduler is currently running on {0[hostname]} with pid {0[pid]}'.format(status)
        else:
            print 'Scheduler is currently NOT running'
        print """
Spooled commands: %(spooled)s

Tasks:
  - Waiting:  %(waiting)s
  - Running:  %(running)s
  - Failed:   %(failed)s
  - Finished: %(finished)s
""" % status
    elif args.field == "spool":

        for op, obj in c.getSpool():
            if op in ['add', 'del']:
                print "%s %s" % (op, obj)
            else:
                print op

    dbi.endRequest()
开发者ID:NIIF,项目名称:indico,代码行数:32,代码来源:daemon_script.py

示例7: register

 def register(interval=15):
     from indico.modules.scheduler import Client
     from dateutil.rrule import MINUTELY
     from indico.core.db import DBMgr
     DBMgr.getInstance().startRequest()
     task = OutlookUpdateCalendarNotificationTask(MINUTELY, interval=interval)
     client = Client()
     client.enqueue(task)
     DBMgr.getInstance().endRequest()
开发者ID:pferreir,项目名称:indico-backup,代码行数:9,代码来源:tasks.py

示例8: addSuggestionsTask

def addSuggestionsTask(dbi, withRBDB, prevVersion):
    """Add Category Suggestion Task to scheduler (Redis needed)"""
    if not Config.getInstance().getRedisConnectionURL():
        print console.colored("  Redis not configured, skipping", 'yellow')
        return
    task = CategorySuggestionTask(rrule.DAILY)
    client = Client()
    client.enqueue(task)
    dbi.commit()
开发者ID:Ictp,项目名称:indico,代码行数:9,代码来源:migrate.py

示例9: _check_running

def _check_running():

    dbi = DBMgr.getInstance()

    dbi.startRequest()
    c = Client()
    running = c.getStatus()['state']
    dbi.endRequest()

    return running
开发者ID:ferhatelmas,项目名称:indico,代码行数:10,代码来源:daemon_script.py

示例10: _cmd

def _cmd(args):

    dbi = DBMgr.getInstance()

    dbi.startRequest()
    c = Client()

    if args.command == "clear_spool":
        print "%s operations removed" % c.clearSpool()

    dbi.endRequest()
开发者ID:NIIF,项目名称:indico,代码行数:11,代码来源:daemon_script.py

示例11: _run

    def _run(self, args):

        if args.action == 'add_task':
            c = Client()
            task = LiveSyncUpdateTask(MINUTELY, interval=args.interval)
            c.enqueue(task)
            self._dbi.commit()
        elif args.action == 'export':
            self._export(args)
            self._dbi.abort()
        elif args.action == 'simulate':
            self._simulate(args)
            self._dbi.abort()
开发者ID:VishrutMehta,项目名称:indico,代码行数:13,代码来源:console.py

示例12: testPriority

    def testPriority(self):
        """
        Checking that one task is executed before another
        """

        self._workers = {}

        global terminated

        terminated = multiprocessing.Array('i', [0, 0])

        terminated[0] = 0
        terminated[1] = 0

        w1 = Worker(0, TestTask, base.TimeSource.get().getCurrentTime() + \
                    timedelta(seconds=4))
        w1.start()

        base.TimeSource.get().sleep(1)

        w2 = Worker(1, TestTask, base.TimeSource.get().getCurrentTime() + \
                    timedelta(seconds=0))
        w2.start()

        self._workers[0] = w1
        self._workers[1] = w2

        w1.join()
        w2.join()

        self.assertEqual(self._checkWorkersFinished(10),
                         True)

        self._assertStatus({'state': True,
                            'waiting': 0,
                            'running': 0,
                            'spooled': 0,
                            'finished': 2,
                            'failed': 0})

        with self._context('database', sync=True):
            c = Client()
            t1 = c.getTask(0)
            t2 = c.getTask(1)

            self.assertEqual(t1.endedOn > t2.endedOn, True)
开发者ID:VishrutMehta,项目名称:indico,代码行数:46,代码来源:server_test.py

示例13: taskMigration

def taskMigration(dbi, withRBDB, prevVersion):
    """
    Migrating database tasks from the old format to the new one
    """

    c = Client()

    for t in HelperTaskList().getTaskListInstance().getTasks():
        for obj in t.listObj.values():
            print console.colored("   * %s" % obj.__class__.__name__, 'blue')
            if obj.__class__.__name__ == 'OfflineWebsiteCreator':
                continue
            if obj.__class__.__name__ == 'FoundationSync':
                c.enqueue(
                    FoundationSyncTask(rrule.DAILY, byhour=0, byminute=0))
            elif obj.__class__.__name__ == 'StatisticsUpdater':
                c.enqueue(CategoryStatisticsUpdaterTask(
                    CategoryManager().getById('0'),
                    rrule.DAILY,
                    byhour=0, byminute=0))
            elif obj.__class__.__name__ == 'sendMail':
                # they have to be somewhere in the conference
                alarm = t.conf.alarmList[t.id]
                c.enqueue(alarm)
            else:
                print console.colored("WARNING: Unknown task type!", 'yellow')

    if withRBDB:
        DALManager.commit()
    dbi.commit()
开发者ID:ferhatelmas,项目名称:indico,代码行数:30,代码来源:migrate.py

示例14: _checkParams

    def _checkParams(self):
        SchedulerModuleAdminService._checkParams(self)
        tid = self._params.get("id", None)

        if tid == None:
            raise ServiceError("ERR-T0", "Task Id not provided")

        self._client = Client()
        self._task = self._client.getTask(tid)
开发者ID:bubbas,项目名称:indico,代码行数:9,代码来源:scheduler.py

示例15: _checkParams

    def _checkParams(self):
        SchedulerModuleAdminService._checkParams(self)
        tid = self._params.get('id', None)

        if tid == None:
            raise ServiceError('ERR-T0','Task Id not provided')

        self._client = Client()
        self._task = self._client.getTask(tid)
开发者ID:NIIF,项目名称:indico,代码行数:9,代码来源:scheduler.py


注:本文中的indico.modules.scheduler.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。