Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupting the workers in Jupyter notebook #14

Closed
wjaskowski opened this issue Mar 16, 2018 · 2 comments
Closed

Interrupting the workers in Jupyter notebook #14

wjaskowski opened this issue Mar 16, 2018 · 2 comments

Comments

@wjaskowski
Copy link

If I run something like that

def f(x):
    r = 0
    for i in range(100000000000):
        r += i
    return r
parmap.map(f, range(100))

in Jupyter notebook, and press "Interrupt the kernel" for the first time, I get some output but the workers are still working. After hitting "Interrupt the kernel" for the second time, most workers are killed (44 on my machine), but (always) 4 are still working 100% CPU. Only hitting "Interrupt" for the third time, clears everything.

Here is my workaround with which "Interrput" works with the first hit

def pmap(function, iterable, *args, **kwargs):
    try:
        pool = Pool(processes=psutil.cpu_count()//2)
        return parmap.map(function, iterable, *args, **kwargs, pm_pool=pool)
    finally:
        pool.terminate()
@zeehio
Copy link
Owner

zeehio commented Mar 16, 2018

Thanks for the bug report. I am using pool.join() instead of terminate, I don't know why that makes the difference, but it makes sense that terminate does not wait for anything to finish.

I will try to find time to fix this. I would like to use pool.join unless there is an error or an interruption.

Thanks again!

@zeehio zeehio closed this as completed in aadd6d4 Apr 30, 2019
@zeehio
Copy link
Owner

zeehio commented Apr 30, 2019

I guess it should work now. A bit late though... sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants