Use Current ioloop in SyncWrapper#67131
Closed
frebib wants to merge 1 commit intosaltstack:masterfrom
Closed
Conversation
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 <jgroocock@cloudflare.com>
Contributor
Author
|
We hit this issue in a slightly different manner to the linked bug ticket, but it's the same problem [ERROR ] Rendering exception occurred
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 471, in render_jinja_tmpl
output = template.render(**decoded_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 162, in get_source
self.check_cache(_template)
File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 116, in check_cache
ret = self.cache_file(template)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 108, in cache_file
fcl = self.file_client()
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/utils/jinja.py", line 97, in file_client
self._file_client = salt.fileclient.get_file_client(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/fileclient.py", line 56, in get_file_client
return {"remote": RemoteClient, "local": FSClient, "pillar": PillarClient}.get(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/fileclient.py", line 1130, in __init__
self.channel = salt.channel.client.ReqChannel.factory(self.opts)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/channel/client.py", line 56, in factory
return SyncWrapper(
^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/utils/asynchronous.py", line 76, in __init__
self.obj = cls(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/channel/client.py", line 133, in factory
auth = salt.crypt.AsyncAuth(opts, io_loop=io_loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/salt/crypt.py", line 697, in __new__
auth.__singleton_init__(opts, io_loop=io_loop)
File "/usr/lib/python3/dist-packages/salt/crypt.py", line 744, in __singleton_init__
self._authenticate_future = tornado.concurrent.Future()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/events.py", line 677, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'MainThread'. |
Contributor
|
I've also added this change to my PR #67096. |
Contributor
|
This can probably be closed in favor of #67096 |
Contributor
Author
|
I'd appreciate the other PR pulling in my commit for attribution of the change, or maybe just merging this first |
Contributor
I will cherry-pick your commit before merging mine. |
Contributor
|
My PR with the cherry-picked commit has been merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
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.
This also needs to be backported to 3007.x (3007.2)
What issues does this PR fix or reference?
Fixes #66775
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.
See GitHub's page on GPG signing for more information about signing commits with GPG.