Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / dogpile / util / nameregistry.pyc
Size: Mime:
ó
ëEYc@s6ddlmZddlZdefd„ƒYZdS(i(t	threadingiÿÿÿÿNtNameRegistrycBsAeZdZejƒZejƒZd„Z	d„Z
d„ZRS(sáGenerates and return an object, keeping it as a
    singleton for a certain identifier for as long as its
    strongly referenced.

    e.g.::

        class MyFoo(object):
            "some important object."
            def __init__(self, identifier):
                self.identifier = identifier

        registry = NameRegistry(MyFoo)

        # thread 1:
        my_foo = registry.get("foo1")

        # thread 2
        my_foo = registry.get("foo1")

    Above, ``my_foo`` in both thread #1 and #2 will
    be *the same object*.   The constructor for
    ``MyFoo`` will be called once, passing the
    identifier ``foo1`` as the argument.

    When thread 1 and thread 2 both complete or
    otherwise delete references to ``my_foo``, the
    object is *removed* from the :class:`.NameRegistry` as
    a result of Python garbage collection.

    :param creator: A function that will create a new
     value, given the identifier passed to the :meth:`.NameRegistry.get`
     method.

    cCs+tjƒ|_tjƒ|_||_dS(s/Create a new :class:`.NameRegistry`.


        N(tweakreftWeakValueDictionaryt_valuesRtRLockt_mutextcreator(tselfR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/util/nameregistry.pyt__init__+scOsYy1||jkr|j|S|j|||ŽSWn!tk
rT|j|||ŽSXdS(s]Get and possibly create the value.

        :param identifier: Hash key for the value.
         If the creation function is called, this identifier
         will also be passed to the creation function.
        :param \*args, \**kw: Additional arguments which will
         also be passed to the creation function if it is
         called.

        N(Rt	_sync_gettKeyError(Rt
identifiertargstkw((sN/home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/util/nameregistry.pytget4s
cOs|jjƒz{yB||jkr-|j|S|j|||Ž|j|<}|SWn2tk
r†|j|||Ž|j|<}|SXWd|jjƒXdS(N(RtacquireRRRtrelease(RRR
Rtvalue((sN/home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/util/nameregistry.pyR
Gs
 
 	(t__name__t
__module__t__doc__RRt_locksRRRR	RR
(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/util/nameregistry.pyRs"			(tcompatRRtobjectR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/dogpile/util/nameregistry.pyt<module>s