Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6461,19 +6461,28 @@ async def f(stacklevel, mode=None):
assert "cdn.bokeh.org" in data


@pytest.mark.skipif(
sys.version_info >= (3, 10), reason="No internal loop in Python 3.10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "_loop" attribute is there in 3.10 - it's just late bound: https://github.com/python/cpython/blob/8acbb93c0763fa53b5959fe05d86ba275c9e8a5b/Lib/asyncio/mixins.py#L28

the tests could be modified to use the asyncio resource first so the loop is always bound before the assert, eg:

await c.gather([c.submit(...)])
assert c._gather_semaphore._loop

)
@gen_cluster(nthreads=[])
async def test_client_gather_semaphore_loop(s):
async with Client(s.address, asynchronous=True) as c:
assert c._gather_semaphore._loop is c.loop.asyncio_loop


@pytest.mark.skipif(
sys.version_info >= (3, 10), reason="No internal loop in Python 3.10"
)
@gen_cluster(client=True)
async def test_as_completed_condition_loop(c, s, a, b):
seq = c.map(inc, range(5))
ac = as_completed(seq)
assert ac.condition._loop == c.loop.asyncio_loop


@pytest.mark.skipif(
sys.version_info >= (3, 10), reason="No internal loop in Python 3.10"
)
def test_client_connectionpool_semaphore_loop(s, a, b):
with Client(s["address"]) as c:
assert c.rpc.semaphore._loop is c.loop.asyncio_loop
Expand Down