本文整理汇总了Python中model.queues.Queue.queue_with_name方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.queue_with_name方法的具体用法?Python Queue.queue_with_name怎么用?Python Queue.queue_with_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.queues.Queue
的用法示例。
在下文中一共展示了Queue.queue_with_name方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _queue_from_request
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def _queue_from_request(self):
queue_name = self.request.get("queue_name")
queue = Queue.queue_with_name(queue_name)
if not queue:
self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
return None
return queue
示例2: post
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def post(self):
queue_name = self.request.get("queue_name")
# FIXME: This queue lookup should be shared between handlers.
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
attachment_id = self._int_from_request("attachment_id")
attachment = Attachment(attachment_id)
last_status = attachment.status_for_queue(queue)
# Ideally we should use a transaction for the calls to
# WorkItems and ActiveWorkItems.
# Only remove it from the queue if the last message is not a retry request.
# Allow removing it from the queue even if there is no last_status for easier testing.
if not last_status or not last_status.is_retry_request():
queue.work_items().remove_work_item(attachment_id)
RecordPatchEvent.stopped(attachment_id, queue_name)
else:
RecordPatchEvent.retrying(attachment_id, queue_name)
# Always release the lock on the item.
queue.active_work_items().expire_item(attachment_id)
示例3: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name):
queue_name = queue_name.lower()
if not Queue.queue_with_name(queue_name):
self.error(404)
return
timestamp = self._get_timestamp()
view_range = self._get_view_range()
time_unit, time_unit_name = charts.get_time_unit(view_range)
all_queue_names = map(Queue.name, Queue.all())
template_values = {
"all_queue_names": all_queue_names,
"patch_data": self._get_patch_data(queue_name, timestamp, view_range),
"queue_data": self._get_queue_data(queue_name, timestamp, view_range),
"queue_name": queue_name,
"seconds_ago_min": 0,
"seconds_ago_max": view_range,
"time_unit_name": time_unit_name,
"time_unit": time_unit,
"timestamp": timestamp,
"view_range": view_range,
"view_range_choices": charts.view_range_choices,
}
self.response.out.write(template.render("templates/queuecharts.html", template_values))
示例4: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name):
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
# FIXME: Patch assignment should probably move into Queue.
patch_id = db.run_in_transaction(self._assign_patch, queue.active_work_items().key(), queue.work_items().item_ids)
if not patch_id:
self.error(404)
return
self.response.out.write(patch_id)
示例5: _work_items_from_request
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def _work_items_from_request(self):
queue_name = self.request.get("queue_name")
queue = Queue.queue_with_name(queue_name)
if not queue:
self.response.out.write("\"%s\" is not in queues %s" % (queue_name, Queue.all()))
return None
items_string = self.request.get("work_items")
work_items = queue.work_items()
work_items.item_ids = self._parse_work_items_string(items_string)
work_items.date = datetime.now()
return work_items
示例6: post
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def post(self):
queue_name = self.request.get("queue_name")
# FIXME: This queue lookup should be shared between handlers.
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
attachment_id = self._int_from_request("attachment_id")
queue.active_work_items().expire_item(attachment_id)
# ReleaseLock is used when a queue neither succeeded nor failed, so it silently releases the patch.
# Let's try other patches before retrying this one, in the interest of fairness, and also because
# another patch could be posted to address queue problems.
queue.work_items().move_to_end(attachment_id)
示例7: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name):
self.response.headers["Access-Control-Allow-Origin"] = "*"
queue_name = queue_name.lower()
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
self.response.headers['Content-Type'] = 'application/json'
status = {
"queue_length": len(queue.work_items().item_ids)
}
self.response.out.write(json.dumps(status))
示例8: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name, bot_id=None):
queue_name = queue_name.lower()
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
statuses = self._fetch_statuses(queue, bot_id)
template_values = {
"page_title": self._page_title(queue, bot_id),
"work_item_rows": self._rows_for_work_items(queue),
"status_groups": self._build_status_groups(statuses),
"bot_id": bot_id,
}
self.response.out.write(template.render("templates/queuestatus.html", template_values))
示例9: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name):
queue_name = queue_name.lower()
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
self.response.headers['Content-Type'] = 'application/json'
status = {
"status_page": self.request.host_url + "/queue-status/" + queue_name,
"queue": self._rows_for_work_items(queue),
"bots": self._bots(queue),
}
dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) or isinstance(obj, datetime.date) else None
self.response.out.write(json.dumps(status, default=dthandler))
示例10: post
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def post(self):
queue_name = self.request.get("queue_name")
# FIXME: This queue lookup should be shared between handlers.
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
attachment_id = self._int_from_request("attachment_id")
attachment = Attachment(attachment_id)
last_status = attachment.status_for_queue(queue)
# Ideally we should use a transaction for the calls to
# WorkItems and ActiveWorkItems.
queue.work_items().remove_work_item(attachment_id)
RecordPatchEvent.stopped(attachment_id, queue_name, last_status.message)
queue.active_work_items().expire_item(attachment_id)
示例11: get
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def get(self, queue_name, bot_id=None):
queue_name = queue_name.lower()
queue = Queue.queue_with_name(queue_name)
if not queue:
self.error(404)
return
statuses = self._fetch_statuses(queue, bot_id)
template_values = {
"page_title": self._page_title(queue, bot_id),
"work_item_rows": self._rows_for_work_items(queue),
"status_groups": self._build_status_groups(statuses),
"bot_id": bot_id,
"last_pass": self._fetch_last_message_matching(queue, bot_id, "Pass"),
"last_boot": self._fetch_last_message_matching(queue, bot_id, "Starting Queue"),
"trailing_month_pass_count": self._fetch_trailing_days_pass_count_string(queue, bot_id, 30),
"trailing_week_pass_count": self._fetch_trailing_days_pass_count_string(queue, bot_id, 7),
}
self.response.out.write(template.render("templates/queuestatus.html", template_values))
示例12: test_queue_with_name
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def test_queue_with_name(self):
self.assertEqual(Queue.queue_with_name("bogus"), None)
self.assertEqual(Queue.queue_with_name("mac-ews").name(), "mac-ews")
self.assertRaises(AssertionError, Queue, ("bogus"))
示例13: _queue_getter
# 需要导入模块: from model.queues import Queue [as 别名]
# 或者: from model.queues.Queue import queue_with_name [as 别名]
def _queue_getter(self):
# Import at runtime to avoid circular imports
from model.queues import Queue
return Queue.queue_with_name(self.queue_name)