Converts ``x`` into a `.Future`. If ``x`` is already a `.Future`, it is simply returned; otherwise it is wrapped in a new `.Future`. This is suitable for use as ``result = yield gen.maybe_future(f())`` when you don't know whether ``f()`` returns a `.Future` or not. .. deprecat
(x: Any)
| 553 | |
| 554 | |
| 555 | def maybe_future(x: Any) -> Future: |
| 556 | """Converts ``x`` into a `.Future`. |
| 557 | |
| 558 | If ``x`` is already a `.Future`, it is simply returned; otherwise |
| 559 | it is wrapped in a new `.Future`. This is suitable for use as |
| 560 | ``result = yield gen.maybe_future(f())`` when you don't know whether |
| 561 | ``f()`` returns a `.Future` or not. |
| 562 | |
| 563 | .. deprecated:: 4.3 |
| 564 | This function only handles ``Futures``, not other yieldable objects. |
| 565 | Instead of `maybe_future`, check for the non-future result types |
| 566 | you expect (often just ``None``), and ``yield`` anything unknown. |
| 567 | """ |
| 568 | if is_future(x): |
| 569 | return x |
| 570 | else: |
| 571 | fut = _create_future() |
| 572 | fut.set_result(x) |
| 573 | return fut |
| 574 | |
| 575 | |
| 576 | def with_timeout( |
nothing calls this directly
no test coverage detected