twisted.internet.defer.maybeDeferred(f, *args, **kw)
function documentationtwisted.internet.defer
View Source
Invoke a function that may or may not return a Deferred
.
Call the given function with the given arguments. If the returned
object is a Deferred
,
return it. If the returned object is a Failure
, wrap
it with fail
and return it. Otherwise, wrap it in succeed
and
return it. If an exception is raised, convert it to a Failure
, wrap
it in fail
, and
then return it.
Parameters | f | The callable to invoke (type: Any callable) |
args | The arguments to pass to f | |
kw | The keyword arguments to pass to f | |
Returns | The result of the function call, wrapped in a Deferred if
necessary. (type: Deferred ) |