code: def acquire_account(self, account=None, owner=None):
          
          with self.unlock_cond:
              if len(self.accounts) == 0:
                  raise ValueError('account pool is empty')
  
              if account:
                  # Specific account requested.
                  while account not in self.unlocked_accounts:
                      self.unlock_cond.wait()
                  self.unlocked_accounts.remove(account)
              else:
                  # Else take the next available one.
                  while len(self.unlocked_accounts) == 0:
                      self.unlock_cond.wait()
                  account = self.unlocked_accounts.popleft()
  
              if owner is not None:
                  self.owner2account[owner].append(account)
                  self.account2owner[account] = owner
              account.acquire(False)
              self.unlock_cond.notify_all()
              return account
docs: Waits until an account becomes available, then locks and returns it.
          If an account is not passed, the next available account is returned.
  
          :type  account: Account
          :param account: The account to be acquired, or None.
          :type  owner: object
          :param owner: An optional descriptor for the owner.
          :rtype:  :class:`Account`
          :return: The account that was acquired.