MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __iter__

Method __iter__

monai/data/thread_buffer.py:68–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

66 self.gen_thread = None
67
68 def __iter__(self):
69 self.is_running = True
70 self.gen_thread = Thread(target=self.enqueue_values, daemon=True)
71 self.gen_thread.start()
72
73 try:
74 while self.is_running and (self.gen_thread.is_alive() or not self.buffer.empty()):
75 try:
76 yield self.buffer.get(timeout=self.timeout)
77 except Empty:
78 pass # queue was empty this time, try again
79 finally:
80 self.stop() # ensure thread completion
81
82
83def buffer_iterator(src, buffer_size: int = 1, timeout: float = 0.01, repeats: int = 1):

Callers 1

__iter__Method · 0.45

Calls 3

stopMethod · 0.95
getMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected