def multiplex(sources): in_q = queue.Queue() consumers = [] for src in sources: t = threading.Thread(target=sendto_queue, args=(src, in_q)) t.start() consumers.append(genfrom_queue(in_q)) return gen_cat(consumers)
def multiplex(sources): """ Generate items from multiple generators """ in_q = queue.Queue() consumers = [] for src in sources: thr = threading.Thread(target=sendto_queue, args=(src, in_q)) thr.start() consumers.append(genfrom_queue(in_q)) return gen_cat(consumers)
def run(self): self.target(genfrom_queue(self.in_q))
def print_r404(log_q): log = genfrom_queue(log_q) print('genfrom_queue: ', log) r404 = (r for r in log if r['status'] == 404) for r in r404: print(r['host'], r['datetime'], r['request'])