#!/usr/bin/env python from multiprocessing import Process, Queue from mybutt import generate_primes, generate_fibs def primes(q): for prime in generate_primes(): q.put(('prime', prime)) def fibs(q): for fib in generate_fibs(): q.put(('fib', fib)) if __name__ == '__main__': q = Queue() pp = Process(target=primes, args=(q,)) fp = Process(target=fibs, args=(q,)) pp.start() fp.start() while True: # print out primes and fibonaccis # as fast as they can be calculated x = q.get() print x