Convert a coroutine function into a function that returns a Deferred. The coroutine function will be called at the time when the wrapper is called. Wrapper args will be passed to it. This is useful for callback chains, as callback functions are called with the previous callback result.
(
coro_f: Callable[_P, Awaitable[_T]],
)
| 404 | |
| 405 | |
| 406 | def deferred_f_from_coro_f( |
| 407 | coro_f: Callable[_P, Awaitable[_T]], |
| 408 | ) -> Callable[_P, Deferred[_T]]: |
| 409 | """Convert a coroutine function into a function that returns a Deferred. |
| 410 | |
| 411 | The coroutine function will be called at the time when the wrapper is called. Wrapper args will be passed to it. |
| 412 | This is useful for callback chains, as callback functions are called with the previous callback result. |
| 413 | """ |
| 414 | |
| 415 | @wraps(coro_f) |
| 416 | def f(*coro_args: _P.args, **coro_kwargs: _P.kwargs) -> Deferred[_T]: |
| 417 | return deferred_from_coro(coro_f(*coro_args, **coro_kwargs)) |
| 418 | |
| 419 | return f |
| 420 | |
| 421 | |
| 422 | def maybeDeferred_coro( |
no outgoing calls
searching dependent graphs…