示例#1
0
 def do_get(self):
     try:
         return self._conns[thread.get_ident()]
     except KeyError:
         c = self.create_connection()
         self._conns[thread.get_ident()] = c
         if len(self._conns) > self.size:
             self.cleanup()
         return c
示例#2
0
文件: pool.py 项目: Eubolist/ankimini
 def do_get(self):
     try:
         return self._conns[thread.get_ident()]
     except KeyError:
         c = self.create_connection()
         self._conns[thread.get_ident()] = c
         if len(self._conns) > self.size:
             self.cleanup()
         return c
示例#3
0
    def connect(self):
        if not self._use_threadlocal:
            return _ConnectionFairy(self).checkout()

        try:
            return self._threadconns[thread.get_ident()].checkout()
        except KeyError:
            agent = _ConnectionFairy(self)
            self._threadconns[thread.get_ident()] = agent
            return agent.checkout()
示例#4
0
文件: pool.py 项目: Eubolist/ankimini
    def connect(self):
        if not self._use_threadlocal:
            return _ConnectionFairy(self).checkout()

        try:
            return self._threadconns[thread.get_ident()].checkout()
        except KeyError:
            agent = _ConnectionFairy(self)
            self._threadconns[thread.get_ident()] = agent
            return agent.checkout()
示例#5
0
 def status(self):
     return "SingletonThreadPool id:%d thread:%d size: %d" % (
         id(self), thread.get_ident(), len(self._conns))
示例#6
0
 def dispose_local(self):
     try:
         del self._conns[thread.get_ident()]
     except KeyError:
         pass
示例#7
0
 def return_conn(self, record):
     if self._use_threadlocal and thread.get_ident() in self._threadconns:
         del self._threadconns[thread.get_ident()]
     self.do_return_conn(record)
示例#8
0
文件: pool.py 项目: Eubolist/ankimini
 def status(self):
     return "SingletonThreadPool id:%d thread:%d size: %d" % (id(self), thread.get_ident(), len(self._conns))
示例#9
0
文件: pool.py 项目: Eubolist/ankimini
 def dispose_local(self):
     try:
         del self._conns[thread.get_ident()]
     except KeyError:
         pass
示例#10
0
文件: pool.py 项目: Eubolist/ankimini
 def return_conn(self, record):
     if self._use_threadlocal and thread.get_ident() in self._threadconns:
         del self._threadconns[thread.get_ident()]
     self.do_return_conn(record)