| 2497 | self.chunks = None # type: ignore |
| 2498 | |
| 2499 | def execute(self) -> Optional[Awaitable[None]]: |
| 2500 | # If template cache is disabled (usually in the debug mode), |
| 2501 | # re-compile templates and reload static files on every |
| 2502 | # request so you don't need to restart to see changes |
| 2503 | if not self.application.settings.get("compiled_template_cache", True): |
| 2504 | with RequestHandler._template_loader_lock: |
| 2505 | for loader in RequestHandler._template_loaders.values(): |
| 2506 | loader.reset() |
| 2507 | if not self.application.settings.get("static_hash_cache", True): |
| 2508 | static_handler_class = self.application.settings.get( |
| 2509 | "static_handler_class", StaticFileHandler |
| 2510 | ) |
| 2511 | static_handler_class.reset() |
| 2512 | |
| 2513 | self.handler = self.handler_class( |
| 2514 | self.application, self.request, **self.handler_kwargs |
| 2515 | ) |
| 2516 | transforms = [t(self.request) for t in self.application.transforms] |
| 2517 | |
| 2518 | if self.stream_request_body: |
| 2519 | self.handler._prepared_future = Future() |
| 2520 | # Note that if an exception escapes handler._execute it will be |
| 2521 | # trapped in the Future it returns (which we are ignoring here, |
| 2522 | # leaving it to be logged when the Future is GC'd). |
| 2523 | # However, that shouldn't happen because _execute has a blanket |
| 2524 | # except handler, and we cannot easily access the IOLoop here to |
| 2525 | # call add_future (because of the requirement to remain compatible |
| 2526 | # with WSGI) |
| 2527 | fut = gen.convert_yielded( |
| 2528 | self.handler._execute(transforms, *self.path_args, **self.path_kwargs) |
| 2529 | ) |
| 2530 | fut.add_done_callback(lambda f: f.result()) |
| 2531 | # If we are streaming the request body, then execute() is finished |
| 2532 | # when the handler has prepared to receive the body. If not, |
| 2533 | # it doesn't matter when execute() finishes (so we return None) |
| 2534 | return self.handler._prepared_future |
| 2535 | |
| 2536 | |
| 2537 | class HTTPError(Exception): |