def threadsafe_generator(f):
    """
    A decorator that takes a generator function and makes it thread-safe.
    """
    @wraps(f)
    def g(*a, **kw):
        return ThreadSafeIter(f(*a, **kw))
    return g

    A decorator that takes a generator function and makes it thread-safe.
    
airtest/utils/threadsafe.py