from typing import Callable


def channel_is_open(func) -> Callable:
    """
    Checks if he Producer channel is opened, else opens a new one.

    func (Callable): wrapped function.
    returns (Callable): the decorated function.
    """

    def wrapper(ins):
        if not ins.channel.is_open:
            new_ch = ins.open_new_channel()
            ins.channel = new_ch
        return func(ins)

    return wrapper