|
101 | 101 | except ImportError: |
102 | 102 | HAS_WIN_FUNCTIONS = False |
103 | 103 |
|
| 104 | +from salt import USE_VENDORED_TORNADO |
| 105 | +if USE_VENDORED_TORNADO: |
| 106 | + from salt.ext.tornado.stack_context import ExceptionStackContext |
| 107 | +else: |
| 108 | + from contextlib import nullcontext as ExceptionStackContext |
104 | 109 |
|
105 | 110 | log = logging.getLogger(__name__) |
106 | 111 |
|
@@ -1675,9 +1680,10 @@ def handle_timeout(*_): |
1675 | 1680 |
|
1676 | 1681 | timeout_handler = handle_timeout |
1677 | 1682 |
|
1678 | | - # pylint: disable=unexpected-keyword-arg |
1679 | | - self._send_req_async(load, timeout) |
1680 | | - # pylint: enable=unexpected-keyword-arg |
| 1683 | + with ExceptionStackContext(timeout_handler): |
| 1684 | + # pylint: disable=unexpected-keyword-arg |
| 1685 | + self._send_req_async(load, timeout) |
| 1686 | + # pylint: enable=unexpected-keyword-arg |
1681 | 1687 | return True |
1682 | 1688 |
|
1683 | 1689 | @tornado.gen.coroutine |
@@ -2251,11 +2257,12 @@ def timeout_handler(*_): |
2251 | 2257 | timeout_handler() |
2252 | 2258 | return "" |
2253 | 2259 | else: |
2254 | | - # pylint: disable=unexpected-keyword-arg |
2255 | | - ret_val = self._send_req_async( |
2256 | | - load, timeout=timeout |
2257 | | - ) |
2258 | | - # pylint: enable=unexpected-keyword-arg |
| 2260 | + with ExceptionStackContext(timeout_handler): |
| 2261 | + # pylint: disable=unexpected-keyword-arg |
| 2262 | + ret_val = self._send_req_async( |
| 2263 | + load, timeout=timeout |
| 2264 | + ) |
| 2265 | + # pylint: enable=unexpected-keyword-arg |
2259 | 2266 |
|
2260 | 2267 | log.trace("ret_val = %s", ret_val) # pylint: disable=no-member |
2261 | 2268 | return ret_val |
@@ -2341,11 +2348,12 @@ def timeout_handler(*_): |
2341 | 2348 | timeout_handler() |
2342 | 2349 | return "" |
2343 | 2350 | else: |
2344 | | - # pylint: disable=unexpected-keyword-arg |
2345 | | - ret_val = self._send_req_async( |
2346 | | - load, timeout=timeout |
2347 | | - ) |
2348 | | - # pylint: enable=unexpected-keyword-arg |
| 2351 | + with ExceptionStackContext(timeout_handler): |
| 2352 | + # pylint: disable=unexpected-keyword-arg |
| 2353 | + ret_val = self._send_req_async( |
| 2354 | + load, timeout=timeout |
| 2355 | + ) |
| 2356 | + # pylint: enable=unexpected-keyword-arg |
2349 | 2357 |
|
2350 | 2358 | log.trace("ret_val = %s", ret_val) # pylint: disable=no-member |
2351 | 2359 | return ret_val |
@@ -3270,18 +3278,19 @@ def timeout_handler(*args): |
3270 | 3278 | log.warning("Unable to forward pub data: %s", args[1]) |
3271 | 3279 | return True |
3272 | 3280 |
|
3273 | | - self.local.pub_async( |
3274 | | - data["tgt"], |
3275 | | - data["fun"], |
3276 | | - data["arg"], |
3277 | | - data["tgt_type"], |
3278 | | - data["ret"], |
3279 | | - data["jid"], |
3280 | | - data["to"], |
3281 | | - io_loop=self.io_loop, |
3282 | | - callback=lambda _: None, |
3283 | | - **kwargs |
3284 | | - ) |
| 3281 | + with ExceptionStackContext(timeout_handler): |
| 3282 | + self.local.pub_async( |
| 3283 | + data["tgt"], |
| 3284 | + data["fun"], |
| 3285 | + data["arg"], |
| 3286 | + data["tgt_type"], |
| 3287 | + data["ret"], |
| 3288 | + data["jid"], |
| 3289 | + data["to"], |
| 3290 | + io_loop=self.io_loop, |
| 3291 | + callback=lambda _: None, |
| 3292 | + **kwargs |
| 3293 | + ) |
3285 | 3294 |
|
3286 | 3295 | def _send_req_sync(self, load, timeout): |
3287 | 3296 | if self.opts["minion_sign_messages"]: |
|
0 commit comments