def builtin_connection_factories(): import moler.connection # installs builtin ones import moler.config.connections as connection_cfg yield # restore since tests may overwrite builtins connection_cfg.register_builtin_connections(moler.connection.ConnectionFactory, moler.connection.ObservableConnection)
def builtin_connection_factories(): import moler.connection # installs builtin ones import moler.config.connections as connection_cfg yield # restore since tests may overwrite builtins connection_cfg.register_builtin_connections(moler.connection_factory.ConnectionFactory, moler.threaded_moler_connection.ThreadedMolerConnection)
io_type) _moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) if variant not in ConnectionFactory.available_variants(io_type): whats_wrong = "is not registered inside ConnectionFactory" err_msg = "'{}' variant of '{}' connection {}".format( variant, io_type, whats_wrong) _moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) return variant def _try_get_connection_with_name(io_type, variant, **constructor_kwargs): try: return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) except TypeError as err: if "unexpected keyword argument 'name'" in str(err): # 'name' parameter not allowed in connection constructor del constructor_kwargs['name'] return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) _moler_logger_log(level=logging.DEBUG, msg=repr(err)) raise # actions during import connection_cfg.register_builtin_connections(ConnectionFactory, ObservableConnection) connection_cfg.set_defaults()
io_type) _moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) if variant not in ConnectionFactory.available_variants(io_type): whats_wrong = "is not registered inside ConnectionFactory" err_msg = "'{}' variant of '{}' connection {}".format( variant, io_type, whats_wrong) _moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) return variant def _try_get_connection_with_name(io_type, variant, **constructor_kwargs): try: return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) except TypeError as err: if "unexpected keyword argument 'name'" in str(err): # 'name' parameter not allowed in connection constructor del constructor_kwargs['name'] return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) _moler_logger_log(level=logging.DEBUG, msg=repr(err)) raise # actions during import connection_cfg.register_builtin_connections(ConnectionFactory, ThreadedMolerConnection) connection_cfg.set_defaults()
_moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) if variant not in ConnectionFactory.available_variants(io_type): whats_wrong = "is not registered inside ConnectionFactory" err_msg = "'{}' variant of '{}' connection {}".format(variant, io_type, whats_wrong) _moler_logger_log(level=logging.DEBUG, msg=err_msg) raise KeyError(err_msg) return variant def _try_get_connection_with_name(io_type, variant, **constructor_kwargs): try: return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) except TypeError as err: if "unexpected keyword argument 'name'" in str(err): # 'name' parameter not allowed in connection constructor del constructor_kwargs['name'] return ConnectionFactory.get_connection(io_type, variant, **constructor_kwargs) _moler_logger_log(level=logging.DEBUG, msg=repr(err)) raise # actions during import # connection_cfg.register_builtin_connections(ConnectionFactory, ThreadedMolerConnection) # Default in Moler 1.x.y connection_cfg.register_builtin_connections(ConnectionFactory, MolerConnectionForSingleThreadRunner) # default since # Moler 2.0.0 connection_cfg.set_defaults()