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


Python dummy_thread.get_ident方法代码示例

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


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

示例1: _recursive_repr

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def _recursive_repr(user_function):
    'Decorator to make a repr function return "..." for a recursive call'
    repr_running = set()

    def wrapper(self):
        key = id(self), get_ident()
        if key in repr_running:
            return '...'
        repr_running.add(key)
        try:
            result = user_function(self)
        finally:
            repr_running.discard(key)
        return result

    # Can't use functools.wraps() here because of bootstrap issues
    wrapper.__module__ = getattr(user_function, '__module__')
    wrapper.__doc__ = getattr(user_function, '__doc__')
    wrapper.__name__ = getattr(user_function, '__name__')
    return wrapper


################################################################################
### OrderedDict
################################################################################ 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:collections.py

示例2: __repr__

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def __repr__(self, _repr_running={}):
        'od.__repr__() <==> repr(od)'
        call_key = id(self), _get_ident()
        if call_key in _repr_running:
            return '...'
        _repr_running[call_key] = 1
        try:
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, self.items())
        finally:
            del _repr_running[call_key] 
开发者ID:war-and-code,项目名称:jawfish,代码行数:14,代码来源:ordered_dict.py

示例3: recursive_repr

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def recursive_repr(fillvalue='...'):
    'Decorator to make a repr function return fillvalue for a recursive call'

    def decorating_function(user_function):
        repr_running = set()

        def wrapper(self):
            key = id(self), get_ident()
            if key in repr_running:
                return fillvalue
            repr_running.add(key)
            try:
                result = user_function(self)
            finally:
                repr_running.discard(key)
            return result

        # Can't use functools.wraps() here because of bootstrap issues
        wrapper.__module__ = getattr(user_function, '__module__')
        wrapper.__doc__ = getattr(user_function, '__doc__')
        wrapper.__name__ = getattr(user_function, '__name__')
        wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
        return wrapper

    return decorating_function


################################################################################
### OrderedDict
################################################################################ 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:32,代码来源:misc.py

示例4: recursive_repr

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def recursive_repr(fillvalue='...'):
    "Decorator to make a repr function return fillvalue for a recursive call."
    # pylint: disable=missing-docstring
    # Copied from reprlib in Python 3
    # https://hg.python.org/cpython/file/3.6/Lib/reprlib.py

    def decorating_function(user_function):
        repr_running = set()

        @wraps(user_function)
        def wrapper(self):
            key = id(self), get_ident()
            if key in repr_running:
                return fillvalue
            repr_running.add(key)
            try:
                result = user_function(self)
            finally:
                repr_running.discard(key)
            return result

        return wrapper

    return decorating_function

###############################################################################
# END Python 2/3 Shims
############################################################################### 
开发者ID:remg427,项目名称:misp42splunk,代码行数:30,代码来源:sortedlist.py

示例5: _recursive_guard

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def _recursive_guard(fillvalue='...'):
    """
    Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs

    Decorates a function such that if it calls itself with the same first
    argument, it returns `fillvalue` instead of recursing.

    Largely copied from reprlib.recursive_repr
    """

    def decorating_function(f):
        repr_running = set()

        @functools.wraps(f)
        def wrapper(self, *args, **kwargs):
            key = id(self), get_ident()
            if key in repr_running:
                return fillvalue
            repr_running.add(key)
            try:
                return f(self, *args, **kwargs)
            finally:
                repr_running.discard(key)

        return wrapper

    return decorating_function


# gracefully handle recursive calls, when object arrays contain themselves 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:arrayprint.py

示例6: __repr__

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def __repr__(self, _repr_running=None):
            'od.__repr__() <==> repr(od)'
            if not _repr_running: _repr_running = {}
            call_key = id(self), _get_ident()
            if call_key in _repr_running:
                return '...'
            _repr_running[call_key] = 1
            try:
                if not self:
                    return '%s()' % (self.__class__.__name__,)
                return '%s(%r)' % (self.__class__.__name__, self.items())
            finally:
                del _repr_running[call_key] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:compat.py

示例7: __repr__

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def __repr__(self, _repr_running={}): # pylint: disable=W0102
        'od.__repr__() <==> repr(od)'
        call_key = id(self), _get_ident()
        if call_key in _repr_running:
            return '...'
        _repr_running[call_key] = 1
        try:
            if not self:
                return '%s()' % (self.__class__.__name__,)
            return '%s(%r)' % (self.__class__.__name__, self.items())
        finally:
            del _repr_running[call_key] 
开发者ID:cea-hpc,项目名称:pcocc,代码行数:14,代码来源:Backports.py

示例8: get_ident

# 需要导入模块: import dummy_thread [as 别名]
# 或者: from dummy_thread import get_ident [as 别名]
def get_ident():
    """Dummy implementation of thread.get_ident().

    Since this module should only be used when threadmodule is not
    available, it is safe to assume that the current process is the
    only thread.  Thus a constant can be safely returned.
    """
    return -1 
开发者ID:glmcdona,项目名称:meddle,代码行数:10,代码来源:dummy_thread.py


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