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:
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.
When using the following code:
An Error occurs:
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.