本文整理汇总了Python中the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.get_by_id方法的具体用法?Python PostponedTaskPrototype.get_by_id怎么用?Python PostponedTaskPrototype.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype
的用法示例。
在下文中一共展示了PostponedTaskPrototype.get_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_logic_task
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def process_logic_task(self, account_id, task_id): # pylint: disable=W0613
hero = self.storage.accounts_to_heroes[account_id]
bundle_id = hero.actions.current_action.bundle_id
if bundle_id in self.storage.ignored_bundles:
return
with self.storage.on_exception(self.logger,
message='LogicWorker.process_logic_task catch exception, while processing hero %d, try to save all bundles except %d',
data=(hero.id, bundle_id),
excluded_bundle_id=bundle_id):
task = PostponedTaskPrototype.get_by_id(task_id)
task.process(self.logger, storage=self.storage)
task.do_postsave_actions()
self.storage.recache_bundle(bundle_id)
示例2: handle_registration
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def handle_registration(self, request):
if not request.user.is_anonymous:
return HANDLE_REGISTRATION_RESULT.NOT_ANONYMOUS
if accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY not in request.session:
return HANDLE_REGISTRATION_RESULT.NO_TASK_ID
task_id = request.session[accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY]
task = PostponedTaskPrototype.get_by_id(task_id)
if task is None:
return HANDLE_REGISTRATION_RESULT.TASK_NOT_FOUND
if not task.state.is_processed:
return HANDLE_REGISTRATION_RESULT.TASK_NOT_PROCESSED
login_user(request, nick=task.internal_logic.account.nick, password=accounts_settings.FAST_REGISTRATION_USER_PASSWORD)
return HANDLE_REGISTRATION_RESULT.USER_LOGINED
示例3: fast
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def fast(self):
if self.account.is_authenticated:
return self.json_error("accounts.registration.fast.already_registered", "Вы уже зарегистрированы")
if conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY in self.request.session:
task_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY]
task = PostponedTaskPrototype.get_by_id(task_id)
if task is not None:
if task.state.is_processed:
return self.json_error(
"accounts.registration.fast.already_processed", "Вы уже зарегистрированы, обновите страницу"
)
if task.state.is_waiting:
return self.json_processing(task.status_url)
# in other case create new task
referer = None
if conf.accounts_settings.SESSION_REGISTRATION_REFERER_KEY in self.request.session:
referer = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_REFERER_KEY]
referral_of_id = None
if conf.accounts_settings.SESSION_REGISTRATION_REFERRAL_KEY in self.request.session:
referral_of_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_REFERRAL_KEY]
action_id = None
if conf.accounts_settings.SESSION_REGISTRATION_ACTION_KEY in self.request.session:
action_id = self.request.session[conf.accounts_settings.SESSION_REGISTRATION_ACTION_KEY]
registration_task = postponed_tasks.RegistrationTask(
account_id=None, referer=referer, referral_of_id=referral_of_id, action_id=action_id
)
task = PostponedTaskPrototype.create(registration_task, live_time=conf.accounts_settings.REGISTRATION_TIMEOUT)
self.request.session[conf.accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY] = task.id
environment.workers.registration.cmd_task(task.id)
return self.json_processing(task.status_url)
示例4: process_logic_task
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def process_logic_task(self, account_id, task_id): # pylint: disable=W0613
task = PostponedTaskPrototype.get_by_id(task_id)
task.process(self.logger, pvp_balancer=self)
task.do_postsave_actions()
示例5: process_task
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def process_task(self, task_id):
task = PostponedTaskPrototype.get_by_id(task_id)
task.process(self.logger)
task.do_postsave_actions()
示例6: process_task
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def process_task(self, task_id):
task = PostponedTaskPrototype.get_by_id(task_id)
task.process(self.logger)
task.save()
示例7: process_wait_task
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import get_by_id [as 别名]
def process_wait_task(self, task_id):
self.tasks[task_id] = PostponedTaskPrototype.get_by_id(task_id)