コード例 #1
0
ファイル: memcache.py プロジェクト: pkarc/python3-memcache
    def __init__(self, servers=['127.0.0.1:11211'], debug=0, transcoder=Transcoder()):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        """
        local.__init__(self)
        self.debug = debug
        self.set_servers(servers)
        self.stats = {}


        #alias function
        self.gets = self.get_multi
        self.deletes = self.delete_multi
        self.destroy = self.disconnect_all
        self.close = self.disconnect_all
        if transcoder is None:
            raise _Error( 'empty transcoder')
        self.transcoder=transcoder
コード例 #2
0
ファイル: memcachedb.py プロジェクト: appliedcode/appscale
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        """
        local.__init__(self)
        self.set_servers(servers)
        self.debug = debug
        self.stats = {}

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
コード例 #3
0
ファイル: http.py プロジェクト: sakisv/py2neo
 def __init__(self, connection_class, host_port):
     local.__init__(self)
     self.__connection_class = connection_class
     self.__host_port = host_port
     self.__active = []
     self.__passive = []
     self.__timeout = float(environ.get("PY2NEO_TIMEOUT", 2))
コード例 #4
0
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        """
        local.__init__(self)
        self.set_servers(servers)
        self.debug = debug
        self.stats = {}

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
コード例 #5
0
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None,
                 server_max_key_length=SERVER_MAX_KEY_LENGTH,
                 server_max_value_length=SERVER_MAX_VALUE_LENGTH,
                 dead_retry=_DEAD_RETRY, socket_timeout=_SOCKET_TIMEOUT,
                 cache_cas = False):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        @param dead_retry: number of seconds before retrying a blacklisted
        server. Default to 30 s.
        @param socket_timeout: timeout in seconds for all calls to a server. Defaults
        to 3 seconds.
        @param cache_cas: (default False) If true, cas operations will be
        cached.  WARNING: This cache is not expired internally, if you have
        a long-running process you will need to expire it manually via
        "client.reset_cas(), or the cache can grow unlimited.
        @param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)
        Data that is larger than this will not be sent to the server.
        @param server_max_value_length: (default SERVER_MAX_VALUE_LENGTH)
        Data that is larger than this will not be sent to the server.
        """
        local.__init__(self)
        self.debug = debug
        self.dead_retry = dead_retry
        self.socket_timeout = socket_timeout
        self.set_servers(servers)
        self.stats = {}
        self.cache_cas = cache_cas
        self.reset_cas()

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length

        #  figure out the pickler style
        file = StringIO()
        try:
            pickler = self.pickler(file, protocol = self.pickleProtocol)
            self.picklerIsKeyword = True
        except TypeError:
            self.picklerIsKeyword = False
コード例 #6
0
ファイル: memcache.py プロジェクト: jonozzz/nosest
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None,
                 server_max_key_length=SERVER_MAX_KEY_LENGTH,
                 server_max_value_length=SERVER_MAX_VALUE_LENGTH,
                 dead_retry=_DEAD_RETRY, socket_timeout=_SOCKET_TIMEOUT,
                 cache_cas = False):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        @param dead_retry: number of seconds before retrying a blacklisted
        server. Default to 30 s.
        @param socket_timeout: timeout in seconds for all calls to a server. Defaults
        to 3 seconds.
        @param cache_cas: (default False) If true, cas operations will be
        cached.  WARNING: This cache is not expired internally, if you have
        a long-running process you will need to expire it manually via
        "client.reset_cas(), or the cache can grow unlimited.
        @param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)
        Data that is larger than this will not be sent to the server.
        @param server_max_value_length: (default SERVER_MAX_VALUE_LENGTH)
        Data that is larger than this will not be sent to the server.
        """
        local.__init__(self)
        self.debug = debug
        self.dead_retry = dead_retry
        self.socket_timeout = socket_timeout
        self.set_servers(servers)
        self.stats = {}
        self.cache_cas = cache_cas
        self.reset_cas()

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length

        #  figure out the pickler style
        file = StringIO()
        try:
            pickler = self.pickler(file, protocol = self.pickleProtocol)
            self.picklerIsKeyword = True
        except TypeError:
            self.picklerIsKeyword = False
コード例 #7
0
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None):

        local.__init__(self)

        super(TestClient, self).__init__(servers, debug=debug,
            pickleProtocol=pickleProtocol, pickler=pickler, unpickler=unpickler,
            pload=pload, pid=pid)

        self.data = {}
        self.token = 0
コード例 #8
0
    def __init__(self, servers, debug=0):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        """
        local.__init__(self)
        self.set_servers(servers)
        self.debug = debug
        self.stats = {}
コード例 #9
0
    def __init__(
        self,
        servers,
        debug=0,
        pickleProtocol=0,
        pickler=pickle.Pickler,
        unpickler=pickle.Unpickler,
        pload=None,
        pid=None,
        server_max_key_length=SERVER_MAX_KEY_LENGTH,
        server_max_value_length=SERVER_MAX_VALUE_LENGTH,
        dead_retry=DEAD_RETRY,
        socket_timeout=SOCKET_TIMEOUT,
        router_class=Router,
    ):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        """
        local.__init__(self)
        self.debug = debug
        self.set_servers(servers, dead_retry, socket_timeout)
        self.router = router_class(self.servers)
        self.stats = {}
        self.cas_ids = {}

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length

        #  figure out the pickler style
        file = StringIO()
        try:
            pickler = self.pickler(file, protocol=self.pickleProtocol)
            self.picklerIsKeyword = True
        except TypeError:
            self.picklerIsKeyword = False
コード例 #10
0
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None):

        local.__init__(self)

        super(TestClient, self).__init__(
            servers, debug=debug,
            pickleProtocol=pickleProtocol, pickler=pickler, unpickler=unpickler,
            pload=pload, pid=pid)

        self.data = {}
        self.token = 0
コード例 #11
0
    def __init__(self,
                 servers,
                 debug=0,
                 pickleProtocol=0,
                 pickler=pickle.Pickler,
                 unpickler=pickle.Unpickler,
                 pload=None,
                 pid=None,
                 server_max_key_length=SERVER_MAX_KEY_LENGTH,
                 server_max_value_length=SERVER_MAX_VALUE_LENGTH):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        """
        local.__init__(self)
        self.debug = debug
        self.set_servers(servers)
        self.stats = {}
        self.cas_ids = {}

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length

        #  figure out the pickler style
        file = StringIO()
        try:
            pickler = self.pickler(file, protocol=self.pickleProtocol)
            self.picklerIsKeyword = True
        except TypeError:
            self.picklerIsKeyword = False
コード例 #12
0
ファイル: memcache.py プロジェクト: j4cbo/chiral
	def __init__(self, servers, debug=False):
		"""
		Create a new Client object with the given list of servers.

		:param servers: `servers` is passed to `set_servers`.
		:param debug: whether to display error messages when a server is unavailable.
		"""

		local.__init__(self)

		self.debug = debug

		self.servers = []
		self.buckets = []

		self.set_servers(servers)
		self.stats = {}
コード例 #13
0
ファイル: memcache.py プロジェクト: ivanov/sycamore
    def __init__(self, servers, debug=0, pickleProtocol=0,
            pickler=pickle.Pickler, unpickler=pickle.Unpickler):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        """
        local.__init__(self)
        self.set_servers(servers)
        self.debug = debug
        self.stats = {}

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
コード例 #14
0
    def __init__(self, servers, debug=0,
                 server_max_key_length=SERVER_MAX_KEY_LENGTH,
                 server_max_value_length=SERVER_MAX_VALUE_LENGTH,
                 socket_timeout=_SOCKET_TIMEOUT):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param socket_timeout: timeout in seconds for all calls to a server. Defaults
        to 3 seconds.
        @param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)
        Data that is larger than this will not be sent to the server.
        @param server_max_value_length: (default SERVER_MAX_VALUE_LENGTH)
        Data that is larger than this will not be sent to the server.
        """
        local.__init__(self)
        self.debug = debug
        self.socket_timeout = socket_timeout
        self.set_servers(servers)
        self.stats = {}
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length
コード例 #15
0
ファイル: __init__.py プロジェクト: gustavi/prewikka
 def __init__(self):
     local.__init__(self)
     self.init(None)
コード例 #16
0
ファイル: http.py プロジェクト: TTia/Pykipedia
 def __init__(self, scheme, host_port):
     local.__init__(self)
     self._scheme = scheme
     self._host_port = host_port
     self._active = []
     self._passive = []
コード例 #17
0
ファイル: test__local.py プロジェクト: zhangzhaolei/gevent
 def __init__(self):
     local.__init__(self)
     self.sentinel = Sentinel()
     created_sentinels.append(id(self.sentinel))
コード例 #18
0
ファイル: http.py プロジェクト: bartaelterman/snippets
 def __init__(self, connection_class, host_port):
     local.__init__(self)
     self.__connection_class = connection_class
     self.__host_port = host_port
     self.__active = []
     self.__passive = []
コード例 #19
0
 def __init__(self):
     local.__init__(self)
     self.info = (None,None,"",(),{})
コード例 #20
0
 def __init__(self, queue):
     local.__init__(self)
     self.registered = False
     self.vote = False
     self.queue = queue
コード例 #21
0
ファイル: http.py プロジェクト: Sapphirine/stackexchange
 def __init__(self, connection_class, host_port):
     local.__init__(self)
     self.__connection_class = connection_class
     self.__host_port = host_port
     self.__active = []
     self.__passive = []
コード例 #22
0
 def __init__(self, stuff, foo=1):
     local.__init__(self)
     self.stuff = stuff
     self.foo = foo
コード例 #23
0
ファイル: __init__.py プロジェクト: Prelude-SIEM/prewikka
 def __init__(self):
     local.__init__(self)
     self.init(None)
コード例 #24
0
ファイル: memcache.py プロジェクト: 5monkeys/python-memcached
    def __init__(self, servers, debug=0, pickleProtocol=0,
                 pickler=pickle.Pickler, unpickler=pickle.Unpickler,
                 pload=None, pid=None,
                 server_max_key_length=SERVER_MAX_KEY_LENGTH,
                 server_max_value_length=SERVER_MAX_VALUE_LENGTH,
                 dead_retry=_DEAD_RETRY, socket_timeout=_SOCKET_TIMEOUT,
                 cache_cas = False, flush_on_reconnect=0):
        """
        Create a new Client object with the given list of servers.

        @param servers: C{servers} is passed to L{set_servers}.
        @param debug: whether to display error messages when a server can't be
        contacted.
        @param pickleProtocol: number to mandate protocol used by (c)Pickle.
        @param pickler: optional override of default Pickler to allow subclassing.
        @param unpickler: optional override of default Unpickler to allow subclassing.
        @param pload: optional persistent_load function to call on pickle loading.
        Useful for cPickle since subclassing isn't allowed.
        @param pid: optional persistent_id function to call on pickle storing.
        Useful for cPickle since subclassing isn't allowed.
        @param dead_retry: number of seconds before retrying a blacklisted
        server. Default to 30 s.
        @param socket_timeout: timeout in seconds for all calls to a server. Defaults
        to 3 seconds.
        @param cache_cas: (default False) If true, cas operations will be
        cached.  WARNING: This cache is not expired internally, if you have
        a long-running process you will need to expire it manually via
        client.reset_cas(), or the cache can grow unlimited.
        @param server_max_key_length: (default SERVER_MAX_KEY_LENGTH)
        Data that is larger than this will not be sent to the server.
        @param server_max_value_length: (default SERVER_MAX_VALUE_LENGTH)
        Data that is larger than this will not be sent to the server.
        @param flush_on_reconnect: optional flag which prevents a scenario that
        can cause stale data to be read: If there's more than one memcached
        server and the connection to one is interrupted, keys that mapped to
        that server will get reassigned to another. If the first server comes
        back, those keys will map to it again. If it still has its data, get()s
        can read stale data that was overwritten on another server. This flag
        is off by default for backwards compatibility.
        """
        local.__init__(self)
        self.debug = debug
        self.dead_retry = dead_retry
        self.socket_timeout = socket_timeout
        self.flush_on_reconnect = flush_on_reconnect
        self.set_servers(servers)
        self.stats = {}
        self.cache_cas = cache_cas
        self.reset_cas()

        # Allow users to modify pickling/unpickling behavior
        self.pickleProtocol = pickleProtocol
        self.pickler = pickler
        self.unpickler = unpickler
        self.persistent_load = pload
        self.persistent_id = pid
        self.server_max_key_length = server_max_key_length
        self.server_max_value_length = server_max_value_length

        #  figure out the pickler style
        file = StringIO()
        try:
            pickler = self.pickler(file, protocol = self.pickleProtocol)
            self.picklerIsKeyword = True
        except TypeError:
            self.picklerIsKeyword = False
コード例 #25
0
 def __init__(self, queue):
     local.__init__(self)
     self.registered = False
     self.vote = False
     self.queue = queue
コード例 #26
0
ファイル: system.py プロジェクト: BlaXpirit/python-csfml
 def __init__(self, value=None):
     _threadlocal.__init__(self)
     self.value = value
コード例 #27
0
ファイル: test__local.py プロジェクト: loganfreeman/gevent
 def __init__(self):
     local.__init__(self)
     self.sentinel = Sentinel()
     created_sentinels.append(id(self.sentinel))
コード例 #28
0
ファイル: threads.py プロジェクト: cameron-simpson/css
 def __init__(self, **kw):
   ''' Initiale the `State`, providing the per-Thread initial values.
   '''
   thread_local.__init__(self)
   for k, v in kw.items():
     setattr(self, k, v)
コード例 #29
0
ファイル: http.py プロジェクト: leourbina/py2neo
 def __init__(self, scheme, host_port):
     local.__init__(self)
     self._scheme = scheme
     self._host_port = host_port
     self._active = []
     self._passive = []