跳至内容

参考资料 hub_sdk/helpers/utils.py

备注

该文件位于https://github.com/ultralytics/hub-sdk/blob/main/ hub_sdk/helpers/utils .py。如果您发现问题,请提交 Pull Request🛠️ 帮助修复。谢谢🙏!



hub_sdk.helpers.utils.threaded(func)

对目标函数进行多线程处理并返回线程。

使用方法:@threaded decorator.

源代码 hub_sdk/helpers/utils.py
def threaded(func):
    """
    Multi-threads a target function and returns thread.

    Usage: @threaded decorator.
    """

    def wrapper(*args, **kwargs):
        """Multi-threads a given function and returns the thread."""
        thread = threading.Thread(target=func, args=args, kwargs=kwargs, daemon=True)
        thread.start()
        return thread

    return wrapper