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.
Python 3.10 shows a deprecation warning when using
asyncio.get_event_loop
while not in an event loop, which is the case when running the syncrender
method for an async template. Useasyncio.run
instead, which manages running in an event loop.generate
is no longer particularly useful when called on an async template, as callingrun
over and over again would create new loops and be inefficient. So it collects the entire render then yields it item by item so that it's still a generator.generate
already doesn't seem particularly useful, as only very simple templates without blocks or other internal buffers will actually yield one statement at a time.I think we should deprecate calling
render
andgenerate
if the template is async. It's a blocking call in async mode, and it doesn't really make sense to render an async environment from sync code, as you'd have to manage everything manually for that to be useful. It also requires ignoring some type errors. Users should callrender_async
from a running loop when using an async environment.DeprecationWarning: There is no current event loop
#1443Checklist:
CHANGES.rst
summarizing the change and linking to the issue... versionchanged::
entries in any relevant code docs.pre-commit
hooks and fix any issues.pytest
andtox
, no tests failed.