def METHOD_NAME(gen):
    last_user = None
    notifications = []
    for message, result in gen:
        if last_user is not None:
            if message.request.user_id != last_user:
                send_notifications(notifications)
                notifications = []
        last_user = message.request.user_id
        notifications.append((message, result))
        yield message, result
    send_notifications(notifications)