docstr: This method is called to write the results to the results queue. We use ``put`` in a non-blocking way so we
  can gracefully terminate the worker thread without being stuck on :func:`Queue.put`.
  
  The method raises :class:`.WorkerTerminationRequested` exception that should be passed through all the way up to
  :func:`WorkerThread.run` which will gracefully terminate main worker loop.
docstr_tok: ["This","method","is","called","to","write","the","results","to","the","results","queue",".","We","use","``","put","``","in","a","non-blocking","way","so","we","can","gracefully","terminate","the","worker","thread","without","being","stuck","on",":","func",":","`","Queue.put","`",".","The","method","raises",":","class",":","`",".WorkerTerminationRequested","`","exception","that","should","be","passed","through","all","the","way","up","to",":","func",":","`","WorkerThread.run","`","which","will","gracefully","terminate","main","worker","loop","."]
code: def _stop_aware_put(self, data):
      """This method is called to write the results to the results queue. We use ``put`` in a non-blocking way so we
      can gracefully terminate the worker thread without being stuck on :func:`Queue.put`.
  
      The method raises :class:`.WorkerTerminationRequested` exception that should be passed through all the way up to
      :func:`WorkerThread.run` which will gracefully terminate main worker loop.
      """
      while True:
          try:
              self._results_queue.put(
                  data, block=True, timeout=IO_TIMEOUT_INTERVAL_S
              )
              return
          except queue.Full:
              pass
  
          if self._stop_event.is_set():
              raise WorkerTerminationRequested()
  
imports: import cProfile
  import pstats
  import random
  import sys
  from threading import Thread, Event
  from traceback import format_exc
  from six.moves import queue
  from petastorm.workers_pool import EmptyResultError, VentilatedItemProcessedMessage
label_desc: Use image node_id 7 for calling the ThreadPool obj's underlying member method code with example usage: obj._stop_aware_put(data) without return types