首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

python-memcached并发调用get/set时出现RunTimeError:Second simultaneous read on fileno 八

2013-03-12 
python-memcached并发调用get/set时出现RunTimeError:Second simultaneous read on fileno 8 detected.出

python-memcached并发调用get/set时出现RunTimeError:Second simultaneous read on fileno 8 detected.

出现异常如下 RuntimeError: Second simultaneous read on fileno 8 detected.  Unless you really know what you're doing, make sure that only one greenthread can read any particular socket.  Consider using a pools.Pool. If you do know what you're doing and want to disable this error, call eventlet.debug.hub_multiple_reader_prevention(False)

class CacheBackend(CacheBackendBase):    '''    Cache in memcached servers.    '''    def __init__(self):        self.value_length = CONF.chunkcache_memcached_value_length        self.servers = CONF.chunkcache_memcached_servers    @staticmethod    def instance():        global CACHE_BACKEND        if CACHE_BACKEND is None:            CACHE_BACKEND = CacheBackend()        return CACHE_BACKEND    def get(self, key, default=None):        client = _connect(self.servers, self.value_length)        result = client.get(str(key))        client.disconnect_all()        return result or default    def exist(self, key):        return self.get(str(key)) != None    def set(self, key, value):        client = _connect(self.servers, self.value_length)        result = client.set(str(key), value)        client.disconnect_all()        if result == 0:            raise exception.MemcacheSetError()        return result    def delete(self, key):        client = _connect(self.servers, self.value_length)        if self.exist(key):            result = client.delete(str(key))            if result == 0:                raise exception.MemcacheDeleteError()        client.disconnect_all()        return True    def clear(self):        # No need for clearing memcached.        return Truedef _connect(servers, value_length=chunkstore.Store.CHUNKSIZE):        return memcache.Client(servers, debug=1,                               server_max_value_length=value_length)

另外想解释下,并不是单例或者维护一个client对象导致,去掉单例,问题一样,而且并发是多进程并发的,也不应该存在什么单例之类的问题。

热点排行