Skip to content

Instantly share code, notes, and snippets.

@aljungberg
Created October 14, 2010 16:35
Show Gist options
  • Save aljungberg/626518 to your computer and use it in GitHub Desktop.
Save aljungberg/626518 to your computer and use it in GitHub Desktop.
# Fix keyboard interrupts when using multiprocessing.pool.imap().
# Usage:
# import fix_multiprocessing.py
from multiprocessing.pool import IMapIterator
def wrapper(func):
def wrap(self, timeout=None):
# Note: the timeout of 1 googol seconds introduces a rather subtle
# bug for Python scripts intended to run many times the age of the universe.
return func(self, timeout=timeout if timeout is not None else 1e100)
return wrap
IMapIterator.next = wrapper(IMapIterator.next)
@gaberosser
Copy link

What a pity, I want to run my code for one googol and one seconds.

@pombredanne
Copy link

@aljungberg what would be the license for this?

@aljungberg
Copy link
Author

@pombredanne sorry for not noticing your message. Let's go with the MIT license for this.

@pombredanne
Copy link

Thanks!

@pombredanne
Copy link

@aljungberg
Copy link
Author

Hah, that's awesome! Thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment