diff --git a/distributed/core.py b/distributed/core.py index dc5f7733fe..e9dae30f49 100644 --- a/distributed/core.py +++ b/distributed/core.py @@ -1197,17 +1197,6 @@ async def close_rpc(self): self.status = Status.closed return await asyncio.gather(*self.close_comms()) - def __enter__(self): - warnings.warn( - "the rpc synchronous context manager is deprecated", - DeprecationWarning, - stacklevel=2, - ) - return self - - def __exit__(self, exc_type, exc_value, traceback): - asyncio.ensure_future(self.close_rpc()) - async def __aenter__(self): return self @@ -1266,18 +1255,6 @@ async def send_recv_from_rpc(**kwargs): async def close_rpc(self): pass - # For compatibility with rpc() - def __enter__(self): - warnings.warn( - "the rpc synchronous context manager is deprecated", - DeprecationWarning, - stacklevel=2, - ) - return self - - def __exit__(self, exc_type, exc_value, traceback): - pass - async def __aenter__(self): return self diff --git a/distributed/worker.py b/distributed/worker.py index 79f24b22da..e4d7d07833 100644 --- a/distributed/worker.py +++ b/distributed/worker.py @@ -1577,7 +1577,7 @@ async def close( # type: ignore setproctitle("dask worker [closing]") if nanny and self.nanny: - with self.rpc(self.nanny) as r: + async with self.rpc(self.nanny) as r: await r.close_gracefully(reason=reason) # Cancel async instructions