Skip to content

Instantly share code, notes, and snippets.

@gzzo
Created March 26, 2018 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzzo/275d02f69e686baa9aebf5688c0b6d65 to your computer and use it in GitHub Desktop.
Save gzzo/275d02f69e686baa9aebf5688c0b6d65 to your computer and use it in GitHub Desktop.
from collections import deque
results = deque(pool.apply_async(...) for job in jobs)
while results:
current = results.popleft()
try:
current_result = current.get(0.1)
process(current_result)
except multiprocessing.TimeoutError:
results.append(current)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment