def test_wait_with_amount(self): pool = ResourcePool([]) now = time.time() with pytest.raises(Empty): # TODO(wickman) We should also be able to round-down for non-integral Amount types. with pool.acquire(timeout=Amount(1, Time.SECONDS) + Amount(10, Time.MILLISECONDS)) as resource: pass elapsed = time.time() - now assert elapsed >= 1.0
def setup_method(self, method): self.pool = ResourcePool([MyResource(i) for i in range(10)])