當前位置: 首頁>>代碼示例>>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方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: 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 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:27,代碼來源:reprlib.py

示例2: recursive_repr

# 需要導入模塊: import _dummy_thread [as 別名]
# 或者: from _dummy_thread import get_ident [as 別名]
def recursive_repr(func):
    """Decorator to prevent infinite repr recursion."""
    repr_running = set()

    @wraps(func)
    def wrapper(self):
        key = id(self), get_ident()

        if key in repr_running:
            return '...'

        repr_running.add(key)

        try:
            return func(self)
        finally:
            repr_running.discard(key)

    return wrapper 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:21,代碼來源:sortedlist.py

示例3: 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:war-and-code,項目名稱:jawfish,代碼行數:10,代碼來源:_dummy_thread.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'

    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

示例5: 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

示例6: 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


# from collections 3.2.1 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:30,代碼來源:helpers.py

示例7: 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

# from collections 3.2.1 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:29,代碼來源:helpers.py

示例8: _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

示例9: 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.__qualname__ = getattr(user_function, '__qualname__')
        wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
        return wrapper

    return decorating_function 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:28,代碼來源:reprlib.py

示例10: 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:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:10,代碼來源:_dummy_thread.py


注:本文中的_dummy_thread.get_ident方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。