66import dask .config
77from dask .highlevelgraph import HighLevelGraph , MaterializedLayer
88
9- from distributed .client import Client
9+ from distributed .client import Client , _del_global_client
1010from distributed .protocol import dumps , loads
1111from distributed .protocol .serialize import ToPickle
1212from distributed .scheduler import Scheduler
1313from distributed .utils import CancelledError
14- from distributed .utils_test import captured_logger
14+ from distributed .utils_test import captured_logger , gen_test
1515from distributed .worker import Worker
1616
1717
@@ -56,7 +56,7 @@ def __dask_distributed_unpack__(cls, state, *args, **kwargs):
5656
5757@pytest .mark .parametrize ("allow_pickle" , [False , True ])
5858@pytest .mark .parametrize ("protocol" , ["tcp" , "inproc" ])
59- @pytest . mark . asyncio
59+ @gen_test ()
6060async def test_non_msgpack_serializable (allow_pickle , protocol ):
6161 async def client_run (log , a , c ):
6262 a = NonMsgPackSerializableLayer ({"x" : 42 })
@@ -82,3 +82,6 @@ async def client_run(log, a, c):
8282 async with Worker (s .listeners [0 ].contact_address ) as a :
8383 async with Client (s .address , asynchronous = True ) as c :
8484 await client_run (log , a , c )
85+ # In order to avoid a timeout in gen_test() when the Scheduler crashes
86+ # because of `allow_pickle=False`, we delete the client explicitly.
87+ _del_global_client (c )
0 commit comments