()
| 487 | future_cell = [None] # type: List[Optional[Future]] |
| 488 | |
| 489 | def run() -> None: |
| 490 | try: |
| 491 | result = func() |
| 492 | if result is not None: |
| 493 | from tornado.gen import convert_yielded |
| 494 | |
| 495 | result = convert_yielded(result) |
| 496 | except Exception: |
| 497 | fut = Future() # type: Future[Any] |
| 498 | future_cell[0] = fut |
| 499 | future_set_exc_info(fut, sys.exc_info()) |
| 500 | else: |
| 501 | if is_future(result): |
| 502 | future_cell[0] = result |
| 503 | else: |
| 504 | fut = Future() |
| 505 | future_cell[0] = fut |
| 506 | fut.set_result(result) |
| 507 | assert future_cell[0] is not None |
| 508 | self.add_future(future_cell[0], lambda future: self.stop()) |
| 509 | |
| 510 | self.add_callback(run) |
| 511 | if timeout is not None: |
nothing calls this directly
no test coverage detected