From 57d0d1dd2c709165db465664189e96f8d98662f1 Mon Sep 17 00:00:00 2001 From: crusaderky Date: Thu, 30 Apr 2026 00:06:50 +0100 Subject: [PATCH] Clean up deprecated rpc synchronous context manager --- distributed/core.py | 23 ----------------------- distributed/worker.py | 2 +- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/distributed/core.py b/distributed/core.py index dc5f7733fe7..e9dae30f49b 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 79f24b22da6..e4d7d078332 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