Switch an asyncio.wait_for in the template helper to async_timeout (#86349)

Switch an asyncio.wait_for in the template helper to async_timeout

Eliminates the extra task when calling async_render_will_timeout
This commit is contained in:
J. Nick Koston 2023-01-21 12:02:03 -10:00 committed by GitHub
parent 2dca826fa9
commit ca4d7634a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,7 @@ from typing import Any, Literal, NoReturn, TypeVar, cast, overload
from urllib.parse import urlencode as urllib_urlencode
import weakref
import async_timeout
from awesomeversion import AwesomeVersion
import jinja2
from jinja2 import pass_context, pass_environment, pass_eval_context
@ -534,7 +535,8 @@ class Template:
try:
template_render_thread = ThreadWithException(target=_render_template)
template_render_thread.start()
await asyncio.wait_for(finish_event.wait(), timeout=timeout)
async with async_timeout.timeout(timeout):
await finish_event.wait()
if self._exc_info:
raise TemplateError(self._exc_info[1].with_traceback(self._exc_info[2]))
except asyncio.TimeoutError: