Skip to content

Commit 722194b

Browse files
committed
small update to move prefetch gen to only if we have multithread
1 parent 40973e8 commit 722194b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

labelbox/data/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def __init__(self, data: Iterable[Any], prefetch_limit=20, num_executors=1):
4040
self._data = data
4141

4242
self.queue = Queue(prefetch_limit)
43-
self._data = ThreadSafeGen(self._data)
4443
self.completed_threads = 0
4544
# Can only iterate over once it the queue.get hangs forever.
46-
self.multithread = False if num_executors == 1 else True
45+
self.multithread = num_executors > 1
4746
self.done = False
4847

4948
if self.multithread:
49+
self._data = ThreadSafeGen(self._data)
5050
self.num_executors = num_executors
5151
self.threads = [
5252
threading.Thread(target=self.fill_queue)

0 commit comments

Comments
 (0)