summaryrefslogtreecommitdiff
path: root/tests/core/test_dogpile.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/core/test_dogpile.py')
-rw-r--r--tests/core/test_dogpile.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/tests/core/test_dogpile.py b/tests/core/test_dogpile.py
index 4ba8556..9dace4f 100644
--- a/tests/core/test_dogpile.py
+++ b/tests/core/test_dogpile.py
@@ -93,11 +93,11 @@ class ConcurrencyTest(TestCase):
log.error("Assertion failed: " + msg, *args)
assert False, msg % args
- def _test_multi(self, num_threads,
- expiretime,
+ def _test_multi(self, num_threads,
+ expiretime,
creation_time,
- num_usages,
- usage_time,
+ num_usages,
+ usage_time,
delay_time,
cache_expire_time=None,
slow_write_time=None,
@@ -113,8 +113,8 @@ class ConcurrencyTest(TestCase):
use_registry = inline_create == 'get_value_plus_created'
if use_registry:
- reg = NameRegistry(dogpile_cls)
- get_dogpile = lambda: reg.get(expiretime)
+ reg = NameRegistry(lambda key, exptime: dogpile_cls(exptime))
+ get_dogpile = lambda: reg.get("somekey", expiretime)
else:
dogpile = dogpile_cls(expiretime)
get_dogpile = lambda: dogpile
@@ -139,7 +139,7 @@ class ConcurrencyTest(TestCase):
if slow_write_time:
effective_creation_time += slow_write_time
- max_stale = (effective_expiretime + effective_creation_time +
+ max_stale = (effective_expiretime + effective_creation_time +
usage_time + delay_time) * 1.1
the_resource = []
@@ -177,8 +177,8 @@ class ConcurrencyTest(TestCase):
if not the_resource:
raise NeedRegenerationException()
if time.time() - the_resource[-1] > cache_expire_time:
- # should never hit a cache invalidation
- # if we've set expiretime below the cache
+ # should never hit a cache invalidation
+ # if we've set expiretime below the cache
# expire time (assuming a cache which
# honors this).
self._assert_log(
@@ -215,7 +215,7 @@ class ConcurrencyTest(TestCase):
@contextlib.contextmanager
def enter_dogpile_block(dogpile):
with dogpile.acquire(
- lambda: create_resource(dogpile),
+ lambda: create_resource(dogpile),
get_value
) as rec:
yield rec
@@ -223,7 +223,7 @@ class ConcurrencyTest(TestCase):
@contextlib.contextmanager
def enter_dogpile_block(dogpile):
with dogpile.acquire(
- lambda: create_resource(dogpile),
+ lambda: create_resource(dogpile),
value_and_created_fn=get_value
) as rec:
yield rec
@@ -258,7 +258,7 @@ class ConcurrencyTest(TestCase):
time_since_create < max_stale,
"Time since create %.4f max stale time %s, "
"total waited %s",
- time_since_create, max_stale,
+ time_since_create, max_stale,
slow_waiters[0]
)
@@ -296,19 +296,19 @@ class ConcurrencyTest(TestCase):
log.info("Test Summary")
log.info("num threads: %s; expiretime: %s; creation_time: %s; "
"num_usages: %s; "
- "usage_time: %s; delay_time: %s",
- num_threads, expiretime, creation_time, num_usages,
+ "usage_time: %s; delay_time: %s",
+ num_threads, expiretime, creation_time, num_usages,
usage_time, delay_time
)
log.info("cache expire time: %s; unsafe cache: %s slow "
- "write time: %s; inline: %s; registry: %s",
- cache_expire_time, unsafe_cache, slow_write_time,
+ "write time: %s; inline: %s; registry: %s",
+ cache_expire_time, unsafe_cache, slow_write_time,
inline_create, use_registry)
- log.info("Estimated run time %.2f actual run time %.2f",
+ log.info("Estimated run time %.2f actual run time %.2f",
expected_run_time, actual_run_time)
- log.info("Effective expiretime (min(cache_exp_time, exptime)) %s",
+ log.info("Effective expiretime (min(cache_exp_time, exptime)) %s",
effective_expiretime)
- log.info("Expected slow waits %s, Total slow waits %s",
+ log.info("Expected slow waits %s, Total slow waits %s",
expected_slow_waiters, slow_waiters[0])
log.info("Total generations %s Max generations expected %s" % (
len(the_resource), expected_generations
@@ -324,7 +324,7 @@ class ConcurrencyTest(TestCase):
)
assert len(the_resource) <= expected_generations,\
"Number of resource generations %d exceeded "\
- "expected %d" % (len(the_resource),
+ "expected %d" % (len(the_resource),
expected_generations)
class DogpileTest(TestCase):