code: async def request_resource(self, type: Type[T_Resource], name: str = 'default') -> T_Resource:
          
          # First try to locate an existing resource in this context and its parents
          value = self.get_resource(type, name)
          if value is not None:
              return value
  
          # Wait until a matching resource or resource factory is available
          signals = [ctx.resource_added for ctx in self.context_chain]
          await wait_event(
              signals, lambda event: event.resource_name == name and type in event.resource_types)
          return self.require_resource(type, name)
docs: Look up a resource in the chain of contexts.
  
          This is like :meth:`get_resource` except that if the resource is not already available, it
          will wait for one to become available.
  
          :param type: type of the requested resource
          :param name: name of the requested resource
          :return: the requested resource