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


Python lockutils.synchronized方法代码示例

本文整理汇总了Python中oslo_concurrency.lockutils.synchronized方法的典型用法代码示例。如果您正苦于以下问题:Python lockutils.synchronized方法的具体用法?Python lockutils.synchronized怎么用?Python lockutils.synchronized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_concurrency.lockutils的用法示例。


在下文中一共展示了lockutils.synchronized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: application_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def application_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, application_id, *args, **kwargs):
        @lockutils.synchronized(application_id)
        def inner():
            return func(self, ctxt, application_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:10,代码来源:server.py

示例2: remote_session_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def remote_session_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, session_id, *args, **kwargs):
        @lockutils.synchronized(session_id)
        def inner():
            return func(self, ctxt, session_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:10,代码来源:server.py

示例3: memoize

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def memoize(lock_name):
    def memoizer_wrapper(func):
        @lockutils.synchronized(lock_name)
        def memoizer(lock_name):
            if lock_name not in _CACHED_THREAD_POOL:
                _CACHED_THREAD_POOL[lock_name] = func()

            return _CACHED_THREAD_POOL[lock_name]

        return memoizer(lock_name)

    return memoizer_wrapper 
开发者ID:openstack,项目名称:searchlight,代码行数:14,代码来源:common.py

示例4: test_synchronized_wrapped_function_metadata

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def test_synchronized_wrapped_function_metadata(self):
        @lockutils.synchronized('whatever', 'test-')
        def foo():
            """Bar."""
            pass

        self.assertEqual('Bar.', foo.__doc__, "Wrapped function's docstring "
                                              "got lost")
        self.assertEqual('foo', foo.__name__, "Wrapped function's name "
                                              "got mangled") 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:12,代码来源:test_lockutils.py

示例5: test_nested_synchronized_external_works

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def test_nested_synchronized_external_works(self):
        """We can nest external syncs."""
        self.config(lock_path=tempfile.mkdtemp(), group='oslo_concurrency')
        sentinel = object()

        @lockutils.synchronized('testlock1', 'test-', external=True)
        def outer_lock():

            @lockutils.synchronized('testlock2', 'test-', external=True)
            def inner_lock():
                return sentinel
            return inner_lock()

        self.assertEqual(sentinel, outer_lock()) 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:16,代码来源:test_lockutils.py

示例6: test_synchronized_without_prefix

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def test_synchronized_without_prefix(self):
        self.config(lock_path=tempfile.mkdtemp(), group='oslo_concurrency')

        @lockutils.synchronized('lock', external=True)
        def test_without_prefix():
            # We can't check much
            pass

        test_without_prefix() 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:11,代码来源:test_lockutils.py

示例7: test_synchronized_prefix_without_hypen

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def test_synchronized_prefix_without_hypen(self):
        self.config(lock_path=tempfile.mkdtemp(), group='oslo_concurrency')

        @lockutils.synchronized('lock', 'hypen', True)
        def test_without_hypen():
            # We can't check much
            pass

        test_without_hypen() 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:11,代码来源:test_lockutils.py

示例8: test_lock_file_exists

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def test_lock_file_exists(self):
        lock_file = os.path.join(self.lock_dir, 'lock-file')

        @lockutils.synchronized('lock-file', external=True,
                                lock_path=self.lock_dir)
        def foo():
            self.assertTrue(os.path.exists(lock_file))

        foo() 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:11,代码来源:test_lockutils.py

示例9: endpoint_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def endpoint_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, endpoint_id, *args, **kwargs):
        @lockutils.synchronized(
            constants.ENDPOINT_LOCK_NAME_FORMAT % endpoint_id,
            external=True)
        def inner():
            return func(self, ctxt, endpoint_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:12,代码来源:server.py

示例10: replica_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def replica_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, replica_id, *args, **kwargs):
        @lockutils.synchronized(
            constants.REPLICA_LOCK_NAME_FORMAT % replica_id,
            external=True)
        def inner():
            return func(self, ctxt, replica_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:12,代码来源:server.py

示例11: schedule_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def schedule_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, replica_id, schedule_id, *args, **kwargs):
        @lockutils.synchronized(
            constants.SCHEDULE_LOCK_NAME_FORMAT % schedule_id,
            external=True)
        def inner():
            return func(self, ctxt, replica_id, schedule_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:12,代码来源:server.py

示例12: task_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def task_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, task_id, *args, **kwargs):
        @lockutils.synchronized(
            constants.TASK_LOCK_NAME_FORMAT % task_id,
            external=True)
        def inner():
            return func(self, ctxt, task_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:12,代码来源:server.py

示例13: parent_tasks_execution_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def parent_tasks_execution_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, task_id, *args, **kwargs):
        task = db_api.get_task(ctxt, task_id)
        @lockutils.synchronized(
            constants.EXECUTION_LOCK_NAME_FORMAT % task.execution_id,
            external=True)
        @lockutils.synchronized(
            constants.TASK_LOCK_NAME_FORMAT % task_id,
            external=True)
        def inner():
            return func(self, ctxt, task_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:16,代码来源:server.py

示例14: tasks_execution_synchronized

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def tasks_execution_synchronized(func):
    @functools.wraps(func)
    def wrapper(self, ctxt, replica_id, execution_id, *args, **kwargs):
        @lockutils.synchronized(
            constants.EXECUTION_LOCK_NAME_FORMAT % execution_id,
            external=True)
        def inner():
            return func(self, ctxt, replica_id, execution_id, *args, **kwargs)
        return inner()
    return wrapper 
开发者ID:cloudbase,项目名称:coriolis,代码行数:12,代码来源:server.py

示例15: get_iscsi_initiators

# 需要导入模块: from oslo_concurrency import lockutils [as 别名]
# 或者: from oslo_concurrency.lockutils import synchronized [as 别名]
def get_iscsi_initiators(adapter, vios_ids=None):
    """Gets the VIOS iSCSI initiators.

     For the first time invocation of this method after process start up,
     it populates initiators data for VIOSes (if specified, otherwise it
     gets active VIOSes from the host) and stores in memory for futher
     lookup.

    :param adapter: The pypowervm adapter
    :param vios_ids: List of VIOS ids to get the initiators. If not
                     specified, a list of active VIOSes for the
                     host is fetched (but only for the first time)
                     through the pypowervm adapter.
    :return: A dict of the form
             {<vios_id>: <list of initiators>}
    """

    global _ISCSI_INITIATORS

    def discover_initiator(vios_id):

        # Get the VIOS id lock for initiator lookup
        @lockutils.synchronized('inititator-lookup-' + vios_id)
        def _discover_initiator():
            if vios_id in _ISCSI_INITIATORS and _ISCSI_INITIATORS[vios_id]:
                return
            else:
                try:
                    initiator = hdisk.discover_iscsi_initiator(
                        adapter, vios_id)
                    _ISCSI_INITIATORS[vios_id] = initiator
                except (pvm_exc.ISCSIDiscoveryFailed,
                        pvm_exc.JobRequestFailed) as e:
                    # TODO(chhagarw): handle differently based on
                    # error codes
                    LOG.error(e)

        _discover_initiator()

    if vios_ids is None and not _ISCSI_INITIATORS:
        vios_list = pvm_partition.get_active_vioses(adapter)
        vios_ids = [vios.uuid for vios in vios_list]

    for vios_id in vios_ids or []:
        discover_initiator(vios_id)

    LOG.debug("iSCSI initiator info: %s" % _ISCSI_INITIATORS)
    return _ISCSI_INITIATORS 
开发者ID:openstack,项目名称:nova-powervm,代码行数:50,代码来源:iscsi.py


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