Skip to content Skip to sidebar Skip to footer

BrokenProcessPool While Running Code In Jupyter Notebook

I am learning about multiprocessing in python. I have the following code snippet: import time import concurrent.futures def wait(seconds): print(f'Waiting {seconds} seconds...

Solution 1:

I got it to work! I saved the wait function in a separate python file called wait.py and imported it in jupyter notebook.

wait.py:

import time

def wait(seconds):
    print(f'Waiting {seconds} seconds...')
    time.sleep(seconds)
    return f'Done'

ipynb file:

import concurrent.futures
import wait

if __name__ == "__main__":
    with concurrent.futures.ProcessPoolExecutor() as executor:
        p = executor.submit(wait.wait,1)
        print(p.result())

Post a Comment for "BrokenProcessPool While Running Code In Jupyter Notebook"