Skip to content

Commit

Permalink
Remove redundant threadgen decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewearl committed Apr 12, 2016
1 parent beb184a commit c5545f2
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import itertools
import multiprocessing
import random
import Queue
import sys
import threading

import cv2
import numpy
Expand Down Expand Up @@ -182,34 +180,6 @@ def wrapped(*args, **kwargs):
return wrapped


def threadgen(f):
@functools.wraps(f)
def wrapped(*args, **kwargs):
def main():
for item in f(*args, **kwargs):
if stop:
break
q.put(item)

q = Queue.Queue(3)
stop = False
thr = threading.Thread(target=main)
thr.start()
try:
while True:
item = q.get()
yield item
finally:
print "Waiting for proc to exit"
stop = True
try:
q.get_nowait()
except Queue.Empty:
pass
thr.join()

return wrapped

@mpgen
def read_batches(batch_size):
def gen_vecs():
Expand Down

0 comments on commit c5545f2

Please sign in to comment.