Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for x in range(num_db_connections):
- self.pool.append(Connection(conn_string,x))
- time_start = time.time()
- while time.time() - time_start < self.max_db_lock_wait_time:
- for conn in self.pool:
- acquired = conn.db_lock.acquire(False)
- if acquired:
- try:
- lst = conn.work()
- finally:
- conn.db_lock.release()
- return lst
- time.sleep(0.05)
- raise Exception('Could not get connection lock in time')
Add Comment
Please, Sign In to add comment