Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. for x in range(num_db_connections):
  2. self.pool.append(Connection(conn_string,x))
  3.  
  4. time_start = time.time()
  5. while time.time() - time_start < self.max_db_lock_wait_time:
  6. for conn in self.pool:
  7. acquired = conn.db_lock.acquire(False)
  8. if acquired:
  9. try:
  10. lst = conn.work()
  11. finally:
  12. conn.db_lock.release()
  13. return lst
  14. time.sleep(0.05)
  15. raise Exception('Could not get connection lock in time')
Add Comment
Please, Sign In to add comment