本文整理汇总了Python中the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.create方法的典型用法代码示例。如果您正苦于以下问题:Python PostponedTaskPrototype.create方法的具体用法?Python PostponedTaskPrototype.create怎么用?Python PostponedTaskPrototype.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype
的用法示例。
在下文中一共展示了PostponedTaskPrototype.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def setUp(self):
super(RefrigeratorTests, self).setUp()
environment.deinitialize()
environment.initialize()
self.worker = environment.workers.refrigerator
self.worker.initialize()
self.task_1 = PostponedTaskPrototype.create(FakePostponedInternalTask(result_state=POSTPONED_TASK_LOGIC_RESULT.WAIT))
self.task_2 = PostponedTaskPrototype.create(FakePostponedInternalTask())
示例2: purchase_lot
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def purchase_lot(buyer_id, lot):
from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype
from the_tale.finances.market import postponed_tasks
invoice = bank_prototypes.InvoicePrototype.create(recipient_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
recipient_id=lot.seller_id,
sender_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
sender_id=buyer_id,
currency=bank_relations.CURRENCY_TYPE.PREMIUM,
amount=lot.price,
description_for_sender=u'Покупка «%s»' % lot.name,
description_for_recipient=u'Продажа «%s»' % lot.name,
operation_uid=u'market-buy-lot-%s' % lot.type)
transaction = bank_transaction.Transaction(invoice.id)
logic_task = postponed_tasks.BuyLotTask(seller_id=lot.seller_id,
buyer_id=buyer_id,
lot_id=lot.id,
transaction=transaction)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.refrigerator.cmd_wait_task(task.id)
return task
示例3: api_get
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def api_get(context):
u'''
Взять новую карту в колоду игрока.
- **адрес:** /game/cards/api/get
- **http-метод:** POST
- **версии:** 1.0
- **параметры:** нет
- **возможные ошибки**: нет
Метод является «неблокирующей операцией» (см. документацию), формат ответа соответствует ответу для всех «неблокирующих операций».
При завершении операции возвращается дополнительная инфрмация:
{
"message": "строка", // описание результата в формате html
"card": <card_info> // описание полученной карты, формат см. в описании формата информации о герое
}
'''
choose_task = heroes_postponed_tasks.GetCardTask(hero_id=context.account_hero.id)
task = PostponedTaskPrototype.create(choose_task)
amqp_environment.environment.workers.supervisor.cmd_logic_task(context.account.id, task.id)
return dext_views.AjaxProcessing(task.status_url)
示例4: api_combine
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def api_combine(context):
u'''
Объединить карты из колоды игрока.
- **адрес:** /game/cards/api/combine
- **http-метод:** POST
- **версии:** 1.0
- **параметры:**
* GET: cards — перечень уникальный идентификаторов карт в колоде игрока через запятую
- **возможные ошибки**:
* cards.api-combine.wrong_cards — указанные карты нельзя объединить
Метод является «неблокирующей операцией» (см. документацию), формат ответа соответствует ответу для всех «неблокирующих операций».
При завершении операции возвращается дополнительная инфрмация:
{
"message": "строка", // описание результата в формате html
"card": <card_info> // описание полученной карты, формат см. в описании формата информации о герое
}
'''
can_combine_status = context.account_hero.cards.can_combine_cards([card.uid for card in context.account_cards])
if not can_combine_status.is_ALLOWED:
raise dext_views.ViewError(code=u'wrong_cards', message=can_combine_status.text)
choose_task = heroes_postponed_tasks.CombineCardsTask(hero_id=context.account_hero.id, cards=[card.uid for card in context.account_cards])
task = PostponedTaskPrototype.create(choose_task)
amqp_environment.environment.workers.supervisor.cmd_logic_task(context.account.id, task.id)
return dext_views.AjaxProcessing(task.status_url)
示例5: test_check_tasks
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def test_check_tasks(self):
self.worker.process_wait_task(self.task_2.id)
self.worker.process_wait_task(self.task_1.id)
self.worker.process_wait_task(PostponedTaskPrototype.create(FakePostponedInternalTask(result_state=POSTPONED_TASK_LOGIC_RESULT.CONTINUE)).id)
self.worker.check_tasks()
self.assertEqual(set(self.worker.tasks.keys()), set([self.task_1.id]))
示例6: test_remove_old_tasks
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def test_remove_old_tasks(self):
task = PostponedTaskPrototype.create(FakePostponedInternalTask())
task.state = POSTPONED_TASK_STATE.PROCESSED
task.save()
removed_task = PostponedTaskPrototype.create(FakePostponedInternalTask())
removed_task.state = POSTPONED_TASK_STATE.ERROR
removed_task.save()
PostponedTaskPrototype.remove_old_tasks()
self.assertEqual(PostponedTask.objects.all().count(), 3)
with mock.patch('the_tale.common.postponed_tasks.conf.postponed_tasks_settings.TASK_LIVE_TIME', -1):
PostponedTaskPrototype.remove_old_tasks()
self.assertEqual(PostponedTask.objects.all().count(), 1)
示例7: test_handle_registration__task_not_processed
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def test_handle_registration__task_not_processed(self):
registration_task = RegistrationTask(account_id=None, referer=None, referral_of_id=None, action_id=None)
task = PostponedTaskPrototype.create(registration_task)
with mock.patch('the_tale.accounts.middleware.login_user') as login_user:
result = self.middleware.handle_registration(self.make_request_html('/', session={accounts_settings.SESSION_REGISTRATION_TASK_ID_KEY: task.id}))
self.assertTrue(result.is_TASK_NOT_PROCESSED)
self.assertEqual(login_user.call_count, 0)
示例8: change_credentials
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def change_credentials(self):
from the_tale.accounts.postponed_tasks import ChangeCredentials
change_credentials_task = ChangeCredentials(task_id=self.id)
task = PostponedTaskPrototype.create(change_credentials_task)
environment.workers.accounts_manager.cmd_task(task.id)
return task
示例9: choose_ability
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def choose_ability(self, ability_id):
choose_task = postponed_tasks.ChooseHeroAbilityTask(hero_id=self.hero.id, ability_id=ability_id)
task = PostponedTaskPrototype.create(choose_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)
示例10: invoke_hero_method
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def invoke_hero_method(self, account_id, hero_id, method_name, method_kwargs):
from the_tale.game.heroes import postponed_tasks as heroes_postponed_tasks
logic_task = heroes_postponed_tasks.InvokeHeroMethodTask(hero_id=hero_id,
method_name=method_name,
method_kwargs=method_kwargs)
task = PostponedTaskPrototype.create(logic_task)
return lambda: environment.workers.supervisor.cmd_logic_task(account_id=account_id, task_id=task.id)
示例11: reset_name
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def reset_name(self):
change_task = postponed_tasks.ChangeHeroTask(hero_id=self.hero.id,
name=names.generator().get_name(self.hero.race, self.hero.gender),
race=self.hero.race,
gender=self.hero.gender)
task = PostponedTaskPrototype.create(change_task)
environment.workers.supervisor.cmd_logic_task(self.hero.account_id, task.id)
return self.json_processing(task.status_url)
示例12: test_initialization
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def test_initialization(self):
from the_tale.common.postponed_tasks.models import PostponedTask
from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype, POSTPONED_TASK_STATE
from the_tale.common.postponed_tasks.postponed_tasks import FakePostponedInternalTask
PostponedTaskPrototype.create(FakePostponedInternalTask())
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 1)
self.worker.process_initialize()
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 0)
self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.RESETED).count(), 1)
self.assertEqual(self.worker.tasks, {})
self.assertEqual(self.worker.accounts_for_tasks, {})
self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1', self.account_2.id: 'game_logic_2'})
self.assertEqual(self.worker.accounts_queues, {})
self.assertTrue(self.worker.initialized)
self.assertFalse(self.worker.wait_next_turn_answer)
self.assertTrue(GameState.is_working())
示例13: activate
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def activate(self, hero, card_uid, data):
data["hero_id"] = hero.id
data["account_id"] = hero.account_id
data["card_uid"] = card_uid
card_task = UseCardTask(processor_id=self.TYPE.value, hero_id=hero.id, data=data)
task = PostponedTaskPrototype.create(card_task)
environment.workers.supervisor.cmd_logic_task(hero.account_id, task.id)
return task
示例14: create
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def create(context):
check_recipients(context.form)
logic_task = postponed_tasks.SendMessagesTask(account_id=context.account.id,
recipients=context.form.c.recipients,
message=context.form.c.text)
task = PostponedTaskPrototype.create(logic_task)
amqp_environment.environment.workers.accounts_manager.cmd_task(task.id)
return dext_views.AjaxProcessing(status_url=task.status_url)
示例15: reset_abilities
# 需要导入模块: from the_tale.common.postponed_tasks.prototypes import PostponedTaskPrototype [as 别名]
# 或者: from the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype import create [as 别名]
def reset_abilities(self):
if not self.hero.abilities.can_reset:
return self.json_error('heroes.reset_abilities.reset_timeout', 'Сброс способностей пока не доступен')
reset_task = postponed_tasks.ResetHeroAbilitiesTask(hero_id=self.hero.id)
task = PostponedTaskPrototype.create(reset_task)
environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)
return self.json_processing(task.status_url)