futures we can make the invocation of this method into future to do this we use threadpoolexecutor imported from the concurrent futures module we will then submit the worker function to the pool for execution this returns reference to future which we can use to obtain the resultfrom time import sleep from concurrent futures import threadpoolexecutor print('setting up the threadpoolexecutor'pool threadpoolexecutor( submit the function ot the pool to run concurrently obtain future from pool print('submitting the worker to the pool'future pool submit(worker' 'print('obtained reference to the future object'futureobtain the result from the future wait if necessary print('future result():'future result()print('done'the output from this issetting up the threadpoolexecutor submitting the worker to the pool aaobtained reference to the future object <future at ea state=runningaaaaaaaafuture result() done notice how the output from the main program and the worker is interwoven with two ' ' being printed out before the message starting 'obtained in this case new threadpoolexecutor is being created with one thread in the pool (typically there would be multiple threads in the pool but one is being used here for illustrative purposesthe submit(method is then used to submit the function worker with the parameter 'ato the threadpoolexecutor for it to schedule execution of the function the submit(method returns future object the main program then waits for the future object to return result (by calling the result(method on the futurethis method can also take timeout to change this example to use processes rather than threads all that is needed is to change the pool executor to processpoolexecutor