We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d96944d commit 4f2c8e3Copy full SHA for 4f2c8e3
salt/utils/asynchronous.py
@@ -125,6 +125,17 @@ def __getattr__(self, key):
125
126
def _wrap(self, key):
127
def wrap(*args, **kwargs):
128
+ try:
129
+ asyncio.get_running_loop()
130
+ except RuntimeError:
131
+ # asyncio.get_running_loop() raises RuntimeError
132
+ # if there is no running loop, so we can run the method
133
+ # directly with no detaching it to the distinct thread.
134
+ # It will make SyncWrapper way faster for the cases
135
+ # when there are no nested SyncWrapper objects used.
136
+ return self.io_loop.run_sync(
137
+ lambda: getattr(self.obj, key)(*args, **kwargs)
138
+ )
139
results = []
140
thread = threading.Thread(
141
target=self._target,
0 commit comments