Exemple #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
Exemple #2
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
Exemple #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()
Exemple #4
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()
Exemple #5
0
 def status(self):
     return "SingletonThreadPool id:%d thread:%d size: %d" % (
         id(self), thread.get_ident(), len(self._conns))
Exemple #6
0
 def dispose_local(self):
     try:
         del self._conns[thread.get_ident()]
     except KeyError:
         pass
Exemple #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)
Exemple #8
0
 def status(self):
     return "SingletonThreadPool id:%d thread:%d size: %d" % (id(self), thread.get_ident(), len(self._conns))
Exemple #9
0
 def dispose_local(self):
     try:
         del self._conns[thread.get_ident()]
     except KeyError:
         pass
Exemple #10
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)