async def send(self, message: Message) -> None:
    '\n        Awaited by the application to send ASGI `lifespan` events.\n        '
    message_type = message['type']
    self.logger.info("%s:  '%s' event received from application.", self.state, message_type)
    if (self.state is LifespanCycleState.CONNECTING):
        if (self.lifespan == 'on'):
            raise LifespanFailure("Lifespan connection failed during startup and lifespan is 'on'.")
        self.state = LifespanCycleState.UNSUPPORTED
        raise LifespanUnsupported('Lifespan protocol appears unsupported.')
    if (message_type not in ('lifespan.startup.complete', 'lifespan.shutdown.complete', 'lifespan.startup.failed', 'lifespan.shutdown.failed')):
        self.state = LifespanCycleState.FAILED
        raise UnexpectedMessage(f"Unexpected '{message_type}' event received.")
    if (self.state is LifespanCycleState.STARTUP):
        if (message_type == 'lifespan.startup.complete'):
            self.startup_event.set()
        elif (message_type == 'lifespan.startup.failed'):
            self.state = LifespanCycleState.FAILED
            self.startup_event.set()
            message = message.get('message', '')
            raise LifespanFailure(f'Lifespan startup failure. {message}')
    elif (self.state is LifespanCycleState.SHUTDOWN):
        if (message_type == 'lifespan.shutdown.complete'):
            self.shutdown_event.set()
        elif (message_type == 'lifespan.shutdown.failed'):
            self.state = LifespanCycleState.FAILED
            self.shutdown_event.set()
            message = message.get('message', '')
            raise LifespanFailure(f'Lifespan shutdown failure. {message}')
Awaited by the application to send ASGI `lifespan` events.
async def send(self, message: Message) -> None:
    '\n        \n        '
    message_type = message['type']
    self.logger.info("%s:  '%s' event received from application.", self.state, message_type)
    if (self.state is LifespanCycleState.CONNECTING):
        if (self.lifespan == 'on'):
            raise LifespanFailure("Lifespan connection failed during startup and lifespan is 'on'.")
        self.state = LifespanCycleState.UNSUPPORTED
        raise LifespanUnsupported('Lifespan protocol appears unsupported.')
    if (message_type not in ('lifespan.startup.complete', 'lifespan.shutdown.complete', 'lifespan.startup.failed', 'lifespan.shutdown.failed')):
        self.state = LifespanCycleState.FAILED
        raise UnexpectedMessage(f"Unexpected '{message_type}' event received.")
    if (self.state is LifespanCycleState.STARTUP):
        if (message_type == 'lifespan.startup.complete'):
            self.startup_event.set()
        elif (message_type == 'lifespan.startup.failed'):
            self.state = LifespanCycleState.FAILED
            self.startup_event.set()
            message = message.get('message', )
            raise LifespanFailure(f'Lifespan startup failure. {message}')
    elif (self.state is LifespanCycleState.SHUTDOWN):
        if (message_type == 'lifespan.shutdown.complete'):
            self.shutdown_event.set()
        elif (message_type == 'lifespan.shutdown.failed'):
            self.state = LifespanCycleState.FAILED
            self.shutdown_event.set()
            message = message.get('message', )
            raise LifespanFailure(f'Lifespan shutdown failure. {message}')