Skip to content

Commit

Permalink
Do not alow get_event to run with async subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Jan 20, 2025
1 parent 4386d7b commit 07d1715
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion salt/utils/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", []))
)
Expand Down
4 changes: 4 additions & 0 deletions salt/utils/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 07d1715

Please sign in to comment.