diff options
Diffstat (limited to 'taskflow/persistence')
-rw-r--r-- | taskflow/persistence/backends/__init__.py | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/taskflow/persistence/backends/__init__.py b/taskflow/persistence/backends/__init__.py index 50f2416..294febe 100644 --- a/taskflow/persistence/backends/__init__.py +++ b/taskflow/persistence/backends/__init__.py @@ -16,7 +16,6 @@ import contextlib -import six from stevedore import driver from taskflow import exceptions as exc @@ -51,30 +50,21 @@ def fetch(conf, namespace=BACKEND_NAMESPACE, **kwargs): is ``{'a': 'b', 'c': 'd'}`` to the constructor of that persistence backend instance. """ - if isinstance(conf, six.string_types): - conf = {'connection': conf} - backend_name = conf['connection'] - try: - uri = misc.parse_uri(backend_name) - except (TypeError, ValueError): - pass - else: - backend_name = uri.scheme - conf = misc.merge_uri(uri, conf.copy()) + backend, conf = misc.extract_driver_and_conf(conf, 'connection') # If the backend is like 'mysql+pymysql://...' which informs the # backend to use a dialect (supported by sqlalchemy at least) we just want # to look at the first component to find our entrypoint backend name... - if backend_name.find("+") != -1: - backend_name = backend_name.split("+", 1)[0] - LOG.debug('Looking for %r backend driver in %r', backend_name, namespace) + if backend.find("+") != -1: + backend = backend.split("+", 1)[0] + LOG.debug('Looking for %r backend driver in %r', backend, namespace) try: - mgr = driver.DriverManager(namespace, backend_name, + mgr = driver.DriverManager(namespace, backend, invoke_on_load=True, invoke_args=(conf,), invoke_kwds=kwargs) return mgr.driver except RuntimeError as e: - raise exc.NotFound("Could not find backend %s: %s" % (backend_name, e)) + raise exc.NotFound("Could not find backend %s: %s" % (backend, e)) @contextlib.contextmanager |