code: def halt(self):
          
          self.status = 'halt'
          # The _halt method is called by _loop.
          if hasattr(
                  self, '_sampling_thread') and self._sampling_thread.isAlive():
              print_('Waiting for current iteration to finish...')
              while self._sampling_thread.isAlive():
                  sleep(.1)
docs: Halt a sampling running in another thread.