def spawn(*args, **kwargs): """Spawns a new thread and runs a function within it. *target* is the desired function to be run with the given *args* and *kwargs* parameters; if *daemon* is True, the thread will be stopped if the parent exits (default False). *name* is a string, if assigned will be given to the thread. The *spawn* function works as well as a decorator. Returns the Thread object which is running the *target* function or decorated one. .. note: The decorator accepts the keywords *daemon* and *name* only. If *target* keyword is not specified, the function will act as a decorator. """ return function_handler(launch_thread, decorate, *args, **kwargs)
def concurrent(*args, **kwargs): """Runs the given function in a concurrent thread, taking care of the results and error management. *target* is the desired function to be run with the given *args* and *kwargs* parameters; if *timeout* is set, the thread will be stopped once expired returning TimeoutError as results. If a *callback* is passed, it will be run after the job has finished with the returned *Task* as parameter. The *concurrent* function works as well as a decorator. Returns a *Task* object. .. note: The decorator accepts the keywords *timeout* and *callback* only. If *target* keyword is not specified, the function will act as a decorator. """ return function_handler(launch_task, decorate, *args, **kwargs)