You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/swarms/structs/agent_job.py

21 lines
574 B

import threading
from typing import Callable, Tuple
class AgentJob(threading.Thread):
"""A class that handles multithreading logic.
Args:
function (Callable): The function to be executed in a separate thread.
args (Tuple): The arguments to be passed to the function.
"""
def __init__(self, function: Callable, args: Tuple):
threading.Thread.__init__(self)
self.function = function
self.args = args
def run(self) -> None:
"""Runs the function in a separate thread."""
self.function(*self.args)