celery / billiard

Multiprocessing Pool Extensions
Other
420 stars 251 forks source link

Timeout arguments not working for everything except apply and apply_async #412

Open liepelt-cornelius opened 2 months ago

liepelt-cornelius commented 2 months ago

When using the following code:

import time
from billiard import Pool

def long_running_task(x):
    time.sleep(10)  # Simulate a long task
    return x * x

if __name__ == '__main__':
    with Pool(processes=2, timeout=[5]) as pool:
        try:
            result = pool.map(long_running_task, (2,))
            print(result)
        except Exception as e:
            print(f"An error occurred: `{e}")

An Error occurs:

image

At the top i added an print statement within the billiard code to show the value of start and timeout. As you can see in the case of map start is not a single value instead it is a list of all starttimes for the processes.