Skip to content

Instantly share code, notes, and snippets.

@aljungberg
Created October 14, 2010 16:35
Show Gist options
  • Select an option

  • Save aljungberg/626518 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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

@pombredanne

Copy link
Copy Markdown

@aljungberg what would be the license for this?

@aljungberg

Copy link
Copy Markdown
Author

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

@pombredanne

Copy link
Copy Markdown

Thanks!

@pombredanne

Copy link
Copy Markdown

@aljungberg

Copy link
Copy Markdown
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