From df81db369c3141fe8b723bbf1c8d62cbd8834a65 Mon Sep 17 00:00:00 2001 From: Leonid Vinogradov Date: Wed, 24 Jul 2024 11:32:52 +0300 Subject: [PATCH] test koechego --- frontik/handler.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/frontik/handler.py b/frontik/handler.py index 394228f15..421d500cf 100644 --- a/frontik/handler.py +++ b/frontik/handler.py @@ -31,7 +31,7 @@ from frontik.futures import AbortAsyncGroup, AsyncGroup from frontik.http_status import ALLOWED_STATUSES, CLIENT_CLOSED_REQUEST, NON_CRITICAL_BAD_GATEWAY from frontik.json_builder import FrontikJsonDecodeError, json_decode -from frontik.loggers import CUSTOM_JSON_EXTRA, JSON_REQUESTS_LOGGER +from frontik.loggers import CUSTOM_JSON_EXTRA, JSON_REQUESTS_LOGGER, bootstrap_logger from frontik.loggers.stages import StagesLogger from frontik.options import options from frontik.timeout_tracking import get_timeout_checker @@ -59,6 +59,10 @@ class RedirectSignal(Exception): pass +class FinishSignal(Exception): + pass + + class HTTPErrorWithPostprocessors(tornado.web.HTTPError): pass @@ -83,6 +87,7 @@ def __init__(self, *args: object) -> None: _remove_control_chars_regex = re.compile(r'[\x00-\x08\x0e-\x1f]') handler_logger = logging.getLogger('handler') +handler_logger2 = bootstrap_logger('xsl_handler', logging.DEBUG) def _fail_fast_policy(fail_fast: bool, waited: bool, host: str, path: str) -> bool: @@ -492,6 +497,8 @@ async def _postprocess(self) -> Any: self.log.info('page was already finished, skipping page producer') return + flag = False + renderer: Any if self.text is not None: renderer = self._generic_producer @@ -499,6 +506,10 @@ async def _postprocess(self) -> Any: renderer = self.json_producer else: renderer = self.xml_producer + flag = True + + if flag: + handler_logger2.error(f'---{self.name}--{renderer.transform_filename}---') self.log.debug('using %s renderer', renderer) rendered_result, meta_info = await renderer() @@ -651,12 +662,12 @@ def finish(self, chunk: Optional[Union[str, bytes, dict]] = None) -> Future[None content_length = sum(len(part) for part in self._write_buffer) self.set_header('Content-Length', content_length) - future = self.flush(include_footers=True) + self._flush() self._finished = True self.on_finish() - return future + raise FinishSignal() - def flush(self, include_footers: bool = False) -> Future[None]: + def _flush(self): assert self.request.connection is not None chunk = b''.join(self._write_buffer) self._write_buffer = [] @@ -671,10 +682,6 @@ def flush(self, include_footers: bool = False) -> Future[None]: self.handler_result_future.set_result((self._status_code, self._reason, self._headers, chunk)) - future = Future() # type: Future[None] - future.set_result(None) - return future - # postprocessors def set_mandatory_header(self, name: str, value: str) -> None: