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