From 96eccc81fd2e7c51ef96a4cd4124904fab470b4a Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Mon, 6 Jan 2025 17:44:33 +0000 Subject: [PATCH] Use Current ioloop in SyncWrapper A new ioloop is created for each SyncWrapper, but is not swapped in automatically (see make_current=False for Tornado) anymore - this means that the context manager (current_ioloop) is needed to access that ioloop for the purposes of the synchronus execution. Signed-off-by: Joe Groocock --- salt/utils/asynchronous.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/utils/asynchronous.py b/salt/utils/asynchronous.py index 316fc5c478d9..2db45ec49bcb 100644 --- a/salt/utils/asynchronous.py +++ b/salt/utils/asynchronous.py @@ -73,7 +73,8 @@ def __init__( self.cls = cls if loop_kwarg: kwargs[self.loop_kwarg] = self.io_loop - self.obj = cls(*args, **kwargs) + with current_ioloop(self.io_loop): + self.obj = cls(*args, **kwargs) self._async_methods = list( set(async_methods + getattr(self.obj, "async_methods", [])) )