A decorator that takes a generator function and makes it thread-safe.

def threadsafe_generator(generator_func):
    """A decorator that takes a generator function and makes it thread-safe.
    """
    def decoration(*args, **keyword_args):
        """A thread-safe decoration for a generator function."""
        return ThreadSafeIter(generator_func(*args, **keyword_args))
    return decoration