import types
    ...
    if isinstance(run_result, types.GeneratorType):
         ....