Run Task in Threads

class arroyo.processing.strategies.run_task_in_threads.RunTaskInThreads(processing_function: Callable[[Message[TStrategyPayload]], TResult], concurrency: int, max_pending_futures: int, next_step: ProcessingStrategy[FilteredPayload | TResult])

This strategy can be used to run IO-bound tasks in parallel.

The user specifies a processing function (a callable that takes a message). For each message received in the submit method, it runs that processing function. Once completed, the message is submitted to the next step (with the payload containing the result of the processing function).

Since the processing function will be run in threads, avoid using objects which can be modified by different threads or protect it using locks.

If there are too many pending futures, we MessageRejected will be raised to notify the stream processor to slow down.

On poll we check for completion of futures. If processing is done, we submit to the next step. If an error occured the original exception will be raised.