Skip to content

Test for pytest -n 4 with pytest xdist with dask_client fixtures #1446

@eddiebergman

Description

@eddiebergman

A recent PR #1417 added the following lines

active_clients: dict[str, Callable] = {}
@fixture(autouse=True)
def clean_up_any_dask_clients(request: FixtureRequest) -> None:
"""Auto injected fixture to close dask clients after each test"""
yield
if any(active_clients):
for adr in list(active_clients.keys()):
if request.config.getoption("verbose") > 1:
print(f"\nFixture closing dask_client at {adr}")
close = active_clients[adr]
close()
del active_clients[adr]

It's not sure how this interacts with parallelized pytest xdist as in theory, the fixture above, which is automatically run at the end of any test, will check to see if their are any clients and then close it. I imagine this will not parallelize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions