class_docstr: Wrapper class to add timeout feature to synchronous iterators
  - timeout: timeout for next(). Default=ZERO_TIMEOUT i.e. no timeout or blocking calls to next. Updated using set_timeout() 
  - sentinel: the object returned by iterator when timeout happens
  - reset_on_next: if set to True, timeout is reset to the value of ZERO_TIMEOUT on each iteration
  
  TimeoutIterator uses a thread internally.
  The thread stops once the iterator exhausts or raises an exception during iteration.
  
  Any exceptions raised within the wrapped iterator are propagated as it is.
  Exception is raised when all elements generated by the actual iterator before exception have been consumed
  Timeout can be set dynamically before going for iteration
class_docstr_tok: ["Wrapper","class","to","add","timeout","feature","to","synchronous","iterators","-","timeout",":","timeout","for","next","(",")",".","Default=ZERO_TIMEOUT","i.e",".","no","timeout","or","blocking","calls","to","next",".","Updated","using","set_timeout","(",")","-","sentinel",":","the","object","returned","by","iterator","when","timeout","happens","-","reset_on_next",":","if","set","to","True",",","timeout","is","reset","to","the","value","of","ZERO_TIMEOUT","on","each","iteration","TimeoutIterator","uses","a","thread","internally",".","The","thread","stops","once","the","iterator","exhausts","or","raises","an","exception","during","iteration",".","Any","exceptions","raised","within","the","wrapped","iterator","are","propagated","as","it","is",".","Exception","is","raised","when","all","elements","generated","by","the","actual","iterator","before","exception","have","been","consumed","Timeout","can","be","set","dynamically","before","going","for","iteration"]
docstr: interrupt and stop the underlying thread.
  the thread actually dies only after interrupt has been set and
  the underlying iterator yields a value after that.
docstr_tok: ["interrupt","and","stop","the","underlying","thread",".","the","thread","actually","dies","only","after","interrupt","has","been","set","and","the","underlying","iterator","yields","a","value","after","that","."]
code: def interrupt(self):
      """
      interrupt and stop the underlying thread.
      the thread actually dies only after interrupt has been set and
      the underlying iterator yields a value after that.
      """
      self._interrupt = True
  
file_path: h2ogpt/iterators/timeout_iterator.py
imports: import queue
  import asyncio
  import threading
  import traceback
label_desc: Use image node_id 5 for calling the TimeoutIterator obj's underlying member method code with example usage: obj.interrupt() without return types