本文整理汇总了Python中pulp.server.db.model.resources.ReservedResource.decrement_num_reservations方法的典型用法代码示例。如果您正苦于以下问题:Python ReservedResource.decrement_num_reservations方法的具体用法?Python ReservedResource.decrement_num_reservations怎么用?Python ReservedResource.decrement_num_reservations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.db.model.resources.ReservedResource
的用法示例。
在下文中一共展示了ReservedResource.decrement_num_reservations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _release_resource
# 需要导入模块: from pulp.server.db.model.resources import ReservedResource [as 别名]
# 或者: from pulp.server.db.model.resources.ReservedResource import decrement_num_reservations [as 别名]
def _release_resource(resource_id):
"""
Do not queue this task yourself, but always use the _queue_release_resource() task instead.
Please see the docblock on that function for an explanation.
When a resource-reserving task is complete, this method must be called with the
resource_id so that the we know when it is safe to unmap a resource_id from
its given queue name.
:param resource_id: The resource that is no longer in use
:type resource_id: basestring
"""
try:
reserved_resource = ReservedResource(resource_id)
reserved_resource.decrement_num_reservations()
# Now we need to decrement the AvailabeQueue that the reserved_resource was using. If the
# ReservedResource does not exist for some reason, we won't know its assigned_queue, but
# these next lines won't execute anyway.
# Remove the '.dq' from the queue name to get the worker name
worker_name = reserved_resource.assigned_queue.rstrip('.dq')
aqc = Criteria(filters={'_id': worker_name})
aq_list = list(resources.filter_available_queues(aqc))
available_queue = aq_list[0]
available_queue.decrement_num_reservations()
except DoesNotExist:
# If we are trying to decrement the count on one of these obejcts, and they don't exist,
# that's OK
pass
示例2: _release_resource
# 需要导入模块: from pulp.server.db.model.resources import ReservedResource [as 别名]
# 或者: from pulp.server.db.model.resources.ReservedResource import decrement_num_reservations [as 别名]
def _release_resource(resource_id):
"""
Do not queue this task yourself, but always use the _queue_release_resource() task instead.
Please see the docblock on that function for an explanation.
When a resource-reserving task is complete, this method must be called with the
resource_id so that the we know when it is safe to unmap a resource_id from
its given queue name.
:param resource_id: The resource that is no longer in use
:type resource_id: basestring
"""
try:
reserved_resource = ReservedResource(resource_id)
reserved_resource.decrement_num_reservations()
except DoesNotExist:
# If we are trying to decrement the count on one of these objects, and they don't exist,
# that's OK
pass