Skip to content

Commit

Permalink
Sets wait_jitter in worker_test.py (#1927)
Browse files Browse the repository at this point in the history
Many tests in worker_test.py set wait_interval to 0.1 but leave
wait_jitter at its default value of 5.0. This sets wait_jitter to 0.05 in
all such tests, which maintains the expected 0.1 jitter time. This should
reduce each wait by about 2.5 seconds, and I've found that it decreases
the running time of the worker tests on my machine by about 15 seconds.
  • Loading branch information
daveFNbuck authored and Tarrasch committed Nov 22, 2016
1 parent 5fe7f92 commit 93d29eb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def run(self):
sch = Scheduler(retry_delay=100, remove_delay=1000, worker_disconnect_delay=10)

with Worker(scheduler=sch, worker_id='X', keep_alive=True, count_uniques=True) as w:
with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1) as w2:
with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1, wait_jitter=0.05) as w2:
self.assertTrue(w.add(a))
self.assertTrue(w2.add(b))

Expand Down Expand Up @@ -579,7 +579,7 @@ def run(self):
sch = Scheduler(retry_delay=100, remove_delay=1000, worker_disconnect_delay=10)

with Worker(scheduler=sch, worker_id='X', keep_alive=True, count_uniques=True) as w:
with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1) as w2:
with Worker(scheduler=sch, worker_id='Y', keep_alive=True, count_uniques=True, wait_interval=0.1, wait_jitter=0.05) as w2:
self.assertTrue(w.add(b))
self.assertTrue(w2.add(b))

Expand Down Expand Up @@ -1644,7 +1644,7 @@ def requires(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
self.assertTrue(w1.add(wt))

self.assertFalse(w1.run())
Expand Down Expand Up @@ -1683,9 +1683,9 @@ def requires(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2:
with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1) as w3:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2:
with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w3:
self.assertTrue(w1.add(wt))
self.assertTrue(w2.add(e2))
self.assertTrue(w3.add(e1))
Expand Down Expand Up @@ -1727,7 +1727,7 @@ def requires(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
self.assertTrue(w1.add(wt))

self.assertFalse(w1.run())
Expand Down Expand Up @@ -1765,9 +1765,9 @@ def requires(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2:
with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1) as w3:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2:
with Worker(scheduler=self.sch, worker_id='Z', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w3:
self.assertTrue(w1.add(wt))
self.assertTrue(w2.add(e1))
self.assertTrue(w3.add(s1))
Expand Down Expand Up @@ -1818,7 +1818,7 @@ def run(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
self.assertTrue(w1.add(wt))

self.assertFalse(w1.run())
Expand Down Expand Up @@ -1866,8 +1866,8 @@ def run(self):

wt = TestWrapperTask()

with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1) as w2:
with Worker(scheduler=self.sch, worker_id='X', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w1:
with Worker(scheduler=self.sch, worker_id='Y', keep_alive=True, wait_interval=0.1, wait_jitter=0.05) as w2:
self.assertTrue(w1.add(wt))
self.assertTrue(w2.add(s1))

Expand Down

0 comments on commit 93d29eb

Please sign in to comment.