Skip to content

Commit

Permalink
backends: allows backendstrings like -b py:path.to.module:backendclass
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasheinrich committed Oct 11, 2017
1 parent 75bfa4b commit df381fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packtivity/backendutils.py
Expand Up @@ -65,13 +65,17 @@ def backend_from_string(backendstring,backendopts = None):
if backendstring == 'foregroundasync':
backend = asyncbackends.ForegroundBackend(**backendopts)
return is_async, backend

if backendstring == 'ipcluster':
backend = asyncbackends.IPythonParallelBackend(**backendopts)
return is_async, backend
if backendstring == 'celery':
backend = asyncbackends.CeleryBackend(**backendopts)
return is_async, backend
if backendstring.startswith('py:'):
_, module, backend = backendstring.split(':')
module = importlib.import_module(module)
backendclass = getattr(module,backend)
return is_async, backendclass(**backendopts)
if backendstring == 'fromenv':
module, backend, _ = os.environ['PACKTIVITY_ASYNCBACKEND'].split(':')
module = importlib.import_module(module)
Expand Down

0 comments on commit df381fe

Please sign in to comment.