From 07d1715b27eb253cdd683d6b014a5b558d3ec3b9 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sat, 18 Jan 2025 20:47:13 -0700 Subject: [PATCH] Do not alow get_event to run with async subscriber --- salt/utils/asynchronous.py | 3 ++- salt/utils/event.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/salt/utils/asynchronous.py b/salt/utils/asynchronous.py index 911088a3c29b..016fe1748d00 100644 --- a/salt/utils/asynchronous.py +++ b/salt/utils/asynchronous.py @@ -63,7 +63,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", [])) ) diff --git a/salt/utils/event.py b/salt/utils/event.py index 983402875d66..b5b0b06ca40b 100644 --- a/salt/utils/event.py +++ b/salt/utils/event.py @@ -75,6 +75,7 @@ import salt.utils.process import salt.utils.stringutils import salt.utils.zeromq +from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) @@ -567,6 +568,9 @@ def _get_event(self, wait, tag, match_func=None, no_block=False): try: if not self.cpub and not self.connect_pub(timeout=wait): break + if not self._run_io_loop_sync: + log.error("Trying to get event with async subscriber") + raise SaltInvocationError("get_event needs synchornous subscriber") raw = self.subscriber.read(timeout=wait) if raw is None: break