(f: Callable, *args, **kw)
Copy of defer.maybeDeferred that also converts coroutines to Deferreds.
Copy of defer.maybeDeferred that also converts coroutines to Deferreds.
Copy of defer . maybeDeferred that also converts coroutines to Deferreds .
def maybeDeferred_coro(f: Callable, *args, **kw) -> Deferred:
    """ Copy of defer.maybeDeferred that also converts coroutines to Deferreds. """
    try:
        result = f(*args, **kw)
    except:  # noqa: E722
        return defer.fail(failure.Failure(captureVars=Deferred.debug))

    if isinstance(result, Deferred):
        return result
    elif asyncio.isfuture(result) or inspect.isawaitable(result):
        return deferred_from_coro(result)
    elif isinstance(result, failure.Failure):
        return defer.fail(result)
    else:
        return defer.succeed(result)
def maybeDeferred_coro ( f : Callable , * args , * * kw ) -> Deferred : try : result = f ( * args , * * kw ) except : # noqa: E722 return defer . fail ( failure . Failure ( captureVars = Deferred . debug ) ) if isinstance ( result , Deferred ) : return result elif asyncio . isfuture ( result ) or inspect . isawaitable ( result ) : return deferred_from_coro ( result ) elif isinstance ( result , failure . Failure ) : return defer . fail ( result ) else : return defer . succeed ( result )