Skip to content

Commit 4738b7e

Browse files
committed
increase the LEASE_TIMEOUT in the tests
1 parent c882348 commit 4738b7e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_task_queue.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
POSTGRES_DSN = os.environ.get(
2222
"POSTGRES_DSN", "postgresql://postgres:password@localhost:15432/postgres"
2323
) # noqa
24-
LEASE_TIMEOUT = 0.1
24+
# We set the lease timeout to 2 seconds, because if the database is slow
25+
# the timeout would be reached while we are still getting the tasks and
26+
# the tests fail.
27+
LEASE_TIMEOUT = 2
2528

2629
logger = logging.getLogger(__name__)
2730

@@ -82,7 +85,7 @@ def test_is_empty(task_queue: TaskQueue):
8285

8386
def test_complete(task_queue: TaskQueue):
8487
# boring case
85-
task_queue.add({"foo": 1}, LEASE_TIMEOUT + 0.1, ttl=1)
88+
task_queue.add({"foo": 1}, LEASE_TIMEOUT, ttl=1)
8689
_, id_, qname = task_queue.get()
8790
assert not task_queue.is_empty()
8891
assert qname == "test_queue"
@@ -100,7 +103,7 @@ def test_complete(task_queue: TaskQueue):
100103

101104

102105
def test_expired(task_queue: TaskQueue):
103-
task_queue.add({"foo": 1}, LEASE_TIMEOUT + 0.1, ttl=1)
106+
task_queue.add({"foo": 1}, LEASE_TIMEOUT, ttl=1)
104107
task_queue.get()
105108
assert not task_queue.is_empty()
106109
time.sleep(LEASE_TIMEOUT + 0.1)

0 commit comments

Comments
 (0)