Skip to content

Commit

Permalink
Speed up semaphore tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Mar 15, 2022
1 parent 7a69b5e commit 8e4f542
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions distributed/tests/test_semaphore.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ async def test_async_ctx(s, a, b):
assert await sem.acquire()


@pytest.mark.slow
def test_worker_dies():
with cluster(
config={
"distributed.scheduler.locks.lease-timeout": "0.1s",
"distributed.scheduler.locks.lease-timeout": "50ms",
"distributed.scheduler.locks.lease-validation-interval": "10ms",
}
) as (scheduler, workers):
with Client(scheduler["address"]) as client:
Expand Down Expand Up @@ -188,9 +188,8 @@ def f(x, release=True):
assert result.count(False) == 9


@pytest.mark.slow
@gen_cluster(client=True, timeout=120)
async def test_close_async(c, s, a, b):
@gen_cluster(client=True, nthreads=[("", 1)])
async def test_close_async(c, s, a):
sem = await Semaphore(name="test")

assert await sem.acquire()
Expand All @@ -209,7 +208,7 @@ async def test_close_async(c, s, a, b):
assert await sem2.acquire()

def f(sem_):
return sem_.acquire()
sem_.acquire(timeout="0.5s")

semaphore_object = s.extensions["semaphores"]
fire_and_forget(c.submit(f, sem_=sem2))
Expand Down Expand Up @@ -514,7 +513,7 @@ def access_limited(val, sem):
assert len(protected_resource) == 0
protected_resource.append(val)
# Interact with the DB
time.sleep(0.2)
time.sleep(0.01)
protected_resource.remove(val)

client.gather(client.map(access_limited, range(10), sem=sem))
Expand Down

0 comments on commit 8e4f542

Please sign in to comment.