def bind(self, container):

        def clone(prototype):
            if prototype.is_bound():
                raise RuntimeError('Cannot `bind` a bound extension.')

            cls = type(prototype)
            args, kwargs = prototype.__params
            instance = cls(*args, **kwargs)
            # instance.container must be a weakref to avoid a strong reference
            # from value to key in the `shared_extensions` weakkey dict
            # see test_extension_sharing.py: test_weakref
            instance.container = weakref.proxy(container)
            return instance

        instance = clone(self)

        # recurse over sub-extensions
        for name, ext in inspect.getmembers(self, is_extension):
            setattr(instance, name, ext.bind(container))
        return instance
Get an instance of this Extension to bind to `container`.
dataset/ETHPy150Open onefinestay/nameko/nameko/extensions.py/Extension.bind