import threading


def threaded(fn):
    """Decorator function for running in a new thread

    `fn` is the function to be run in a new thread.
    The thread is started and the thread object is returned.
    """
    def threaded_fun(*args, **kwargs):
        t = threading.Thread(target=fn, args=args, kwargs=kwargs)
        t.start()
        return t
    return threaded_fun