Skip to content

Reference for hub_sdk/helpers/utils.py

Note

This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/helpers/utils.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!


hub_sdk.helpers.utils.threaded

threaded(func)

Multi-threads a target function and returns thread.

Usage: @threaded decorator.

Source code in 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