def maybeDeferred(f, *args, **kw):
 try:
  result = f(*args, **kw)
 except:
  return fail(failure.Failure(captureVars=Deferred.debug))
 if isinstance(result, Deferred):
  return result
 elif isinstance(result, failure.Failure):
  return fail(result)
 else:
  return succeed(result)

def maybeDeferred ( f , * args , ** kw ) : try : result = f ( * args , ** kw ) except : return fail ( failure . Failure ( captureVars = Deferred . debug ) ) if isinstance ( result , Deferred ) : return result elif isinstance ( result , failure . Failure ) : return fail ( result ) else : return succeed ( result )
invoke a function that may or may not return a l{deferred} .