From 8faa863611ea5749fd5551c30e92954ae2f2d62c Mon Sep 17 00:00:00 2001 From: Greg Leclercq Date: Tue, 8 Jul 2014 15:15:53 +0200 Subject: [PATCH] Update Executor.submit(): handle TypeError exceptions of issubclass() and isinstance() --- simpleflow/executor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/simpleflow/executor.py b/simpleflow/executor.py index d677dab68..d329522b1 100644 --- a/simpleflow/executor.py +++ b/simpleflow/executor.py @@ -96,11 +96,14 @@ def submit(self, func, *args, **kwargs): except exceptions.ExecutionBlocked: return futures.Future() - if isinstance(func, Activity): - task = self.make_activity_task(func, *args, **kwargs) - elif issubclass(func, Workflow): - task = self.make_workflow_task(func, *args, **kwargs) - else: + try: + if isinstance(func, Activity): + task = self.make_activity_task(func, *args, **kwargs) + elif issubclass(func, Workflow): + task = self.make_workflow_task(func, *args, **kwargs) + else: + raise TypeError + except TypeError: raise TypeError('invalid type {} for {}'.format( type(func), func))