Ticket #8443: postgres-idle.patch
| File postgres-idle.patch, 1.7 KB (added by mixedpuppy, 3 years ago) |
|---|
-
pool.py
132 132 def _return_cnx(self, cnx, key, tid): 133 133 self._available.acquire() 134 134 try: 135 assert (tid, key) in self._active 136 cnx, num = self._active[(tid, key)] 135 #assert (tid, key) in self._active 136 # get the active connection and return it to the pool 137 cnx, num = self._active.get((tid, key), (None,0)) 138 if not cnx: return 139 137 140 if num == 1: 138 141 del self._active[(tid, key)] 139 142 self._available.notify() … … 146 149 finally: 147 150 self._available.release() 148 151 149 def shutdown(self, tid=None): 152 def _return_active_cnx(self, tid, connector, kwargs): 153 if not connector or not kwargs: 154 return 155 key = unicode(kwargs) 156 # shutdown is called at the end of every request, return the 157 # socket connection to the pool if there is one 158 cnx, num = self._active.get((tid, key), (None,0)) 159 if cnx: 160 self._active[(tid, key)] = (cnx, 1) 161 self._return_cnx(cnx, key, tid) 162 163 def shutdown(self, tid=None, connector=None, kwargs=None): 150 164 """Close pooled connections not used in a while""" 165 self._return_active_cnx(tid, connector, kwargs) 151 166 delay = 120 152 167 if tid is None: 153 168 delay = 0 … … 176 191 return _backend.get_cnx(self._connector, self._kwargs, timeout) 177 192 178 193 def shutdown(self, tid=None): 179 _backend.shutdown(tid )194 _backend.shutdown(tid, self._connector, self._kwargs) 180 195
