Skip to content

Commit

Permalink
Fix distributed tests on upstream-dev (#3989)
Browse files Browse the repository at this point in the history
* switch from pre-3.5 style coroutines to async def / await

* update whats-new.rst
  • Loading branch information
keewis authored Apr 21, 2020
1 parent 6a6f2c8 commit b62a3fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ Internal Changes
- Add a CI job that runs the tests with every optional dependency
except ``dask``. (:issue:`3794`, :pull:`3919`)
By `Justus Magin <https://github.com/keewis>`_.

- Use ``async`` / ``await`` for the asynchronous distributed
tests. (:issue:`3987`, :pull:`3989`)
By `Justus Magin <https://github.com/keewis>`_.

.. _whats-new.0.15.1:

Expand Down
8 changes: 4 additions & 4 deletions xarray/tests/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_dask_distributed_cfgrib_integration_test(loop):
reason="Need recent distributed version to clean up get",
)
@gen_cluster(client=True, timeout=None)
def test_async(c, s, a, b):
async def test_async(c, s, a, b):
x = create_test_data()
assert not dask.is_dask_collection(x)
y = x.chunk({"dim2": 4}) + 10
Expand All @@ -206,7 +206,7 @@ def test_async(c, s, a, b):
assert futures_of(z)

future = c.compute(z)
w = yield future
w = await future
assert not dask.is_dask_collection(w)
assert_allclose(x + 10, w)

Expand All @@ -218,7 +218,7 @@ def test_hdf5_lock():


@gen_cluster(client=True)
def test_serializable_locks(c, s, a, b):
async def test_serializable_locks(c, s, a, b):
def f(x, lock=None):
with lock:
return x + 1
Expand All @@ -233,7 +233,7 @@ def f(x, lock=None):
]:

futures = c.map(f, list(range(10)), lock=lock)
yield c.gather(futures)
await c.gather(futures)

lock2 = pickle.loads(pickle.dumps(lock))
assert type(lock) == type(lock2)

0 comments on commit b62a3fb

Please sign in to comment.