예제 #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)