New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require async/await usage in templates #1191
Comments
Based on the docs, the intention seems to be that the template designer doesn't need to understand what type of function was passed, they could continue to write templates as they always had. Whether this has actually been beneficial is impossible to measure. The main benefit I see is a sort of re-wording of that. By not requiring the I can envision making As to using asyncio features, I'm not clear what we'd have to do not to, but I'm open to it. It looks like all it's used for right now is to get an event loop when patching some functions. |
I think an additional I'm also not sure if asyncio features are required, but aiming to avoid them would certainly help support other event loops. |
I'm also in favour of adding explicit/strict mode, at least as an option. Perhaps someone maintaining a library with templates might think differently, but as far as your own code where you control both front-end and back-end is concerned, being explicit with |
@nirvana-msu It sounds like you've misunderstood the strict mode I'm proposing. It would not add or require the |
@davidism indeed - I misinterpreted what "new |
The current async mode happily allows coroutines to be awaited without requiring the
await
keyword. Whilst this is nice, it is actually quite a confusing and a non-obvious behavior.In addition it doesn't always work, for example(Edit: The if statement does work, I'm unsure about{% if coroutine %}
, and I'm not sure{% async for ...
or{% async with ...
work.async for
orasync with
)I propose that templating engine understand and require the usage of the
async
andawait
keywords dropping the current support for nonawait
ed coroutines.It would also be nice if the engine did not use any
asyncio
features so as to be event loop agnostic.The text was updated successfully, but these errors were encountered: