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


Python ReservedResource.decrement_num_reservations方法代码示例

本文整理汇总了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
开发者ID:jbennett7,项目名称:pulp,代码行数:30,代码来源:tasks.py

示例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
开发者ID:unixbhaskar,项目名称:pulp,代码行数:21,代码来源:tasks.py


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