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


Python PostponedTaskPrototype.reset_all方法代码示例

本文整理汇总了Python中the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.reset_all方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.reset_all方法的具体用法?Python PostponedTaskPrototype.reset_all怎么用?Python PostponedTaskPrototype.reset_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype的用法示例。


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

示例1: initialize

# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import reset_all [as 别名]
    def initialize(self):
        self.clean_queues()

        self.gracefull_stop_required = False

        self.time = prototypes.TimePrototype.get_current_time()

        PostponedTaskPrototype.reset_all()

        self.logic_workers = {worker.name: worker for worker in (environment.workers.logic_1, environment.workers.logic_2)}

        self.logger.info('initialize logic')

        self.logic_multicast('initialize', arguments=dict(turn_number=self.time.turn_number), worker_id=True, wait_answer=True)

        if conf.game_settings.ENABLE_WORKER_HIGHLEVEL:
            self.logger.info('initialize highlevel')
            environment.workers.highlevel.cmd_initialize(turn_number=self.time.turn_number, worker_id='highlevel')
            self.wait_answers_from('initialize', workers=['highlevel'])
        else:
            self.logger.info('skip initialization of highlevel')

        if conf.game_settings.ENABLE_PVP:
            self.logger.info('initialize pvp balancer')
            environment.workers.pvp_balancer.cmd_initialize(worker_id='pvp_balancer')
            self.wait_answers_from('initialize', workers=['pvp_balancer'])
        else:
            self.logger.info('skip initialization of pvp balancer')

        self.logger.info('child workers initialized')

        self.logger.info('register task')

        self.tasks = {}
        self.accounts_for_tasks = {}
        self.accounts_owners = {}
        self.accounts_queues = {}
        self.logic_accounts_number = {logic_worker_name: 0 for logic_worker_name in self.logic_workers.keys()}

        for task_model in models.SupervisorTask.objects.filter(state=relations.SUPERVISOR_TASK_STATE.WAITING).iterator():
            task = prototypes.SupervisorTaskPrototype(task_model)
            self.register_task(task, release_accounts=False)

        self.logger.info('distribute accounts')

        for account_id in Account.objects.all().order_by('id').values_list('id', flat=True).iterator():
            self.register_account(account_id)

        self.initialized = True
        self.wait_next_turn_answer = False

        prototypes.GameState.start()

        self.logger.info('SUPERVISOR INITIALIZED')
开发者ID:,项目名称:,代码行数:56,代码来源:

示例2: test_reset_all

# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import reset_all [as 别名]
    def test_reset_all(self):
        task = PostponedTaskPrototype.create(FakePostponedInternalTask())
        task.state = POSTPONED_TASK_STATE.PROCESSED
        task.save()

        self.assertEqual(PostponedTask.objects.all().count(), 2)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 1)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.PROCESSED).count(), 1)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.RESETED).count(), 0)

        PostponedTaskPrototype.reset_all()

        self.assertEqual(PostponedTask.objects.all().count(), 2)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 0)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.PROCESSED).count(), 1)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.RESETED).count(), 1)
开发者ID:,项目名称:,代码行数:18,代码来源:

示例3: initialize

# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import reset_all [as 别名]
 def initialize(self):
     self.initialized = True
     PostponedTaskPrototype.reset_all()
     self.logger.info('REGISTRATION INITIALIZED')
开发者ID:Jazzis18,项目名称:the-tale,代码行数:6,代码来源:registration.py

示例4: initialize

# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import reset_all [as 别名]
 def initialize(self):
     self.initialized = True
     self.next_task_process_time = datetime.datetime.now()
     self.tasks = {}
     PostponedTaskPrototype.reset_all()
     self.logger.info('REFRIGERATOR INITIALIZED')
开发者ID:Alkalit,项目名称:the-tale,代码行数:8,代码来源:refrigerator.py


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