Exemplo n.º 1
0
    def test_stop(self):
        """
    Runs a DescriptorReader over the root directory, then checks that calling
    stop() makes it terminate in a timely fashion.
    """

        # Skip on windows since SIGALRM is unavailable

        if system.is_windows():
            test.runner.skip(self, '(SIGALRM unavailable)')

        is_test_running = True
        reader = stem.descriptor.reader.DescriptorReader('/usr')

        # Fails the test after a couple seconds if we don't finish successfully.
        # Depending on what we're blocked on this might not work when the test
        # fails, requiring that we give a manual kill to the test.

        def timeout_handler(signum, frame):
            if is_test_running:
                self.fail()

        signal.signal(signal.SIGALRM, timeout_handler)
        signal.alarm(2)

        reader.start()
        time.sleep(0.1)
        reader.stop()
        is_test_running = False
Exemplo n.º 2
0
 def test_stop(self):
   """
   Runs a DescriptorReader over the root directory, then checks that calling
   stop() makes it terminate in a timely fashion.
   """
   
   # Skip on windows since SIGALRM is unavailable
   if system.is_windows(): test.runner.skip(self, "(SIGALRM unavailable)")
   
   is_test_running = True
   reader = stem.descriptor.reader.DescriptorReader("/usr")
   
   # Fails the test after a couple seconds if we don't finish successfully.
   # Depending on what we're blocked on this might not work when the test
   # fails, requiring that we give a manual kill to the test.
   
   def timeout_handler(signum, frame):
     if is_test_running:
       self.fail()
   
   signal.signal(signal.SIGALRM, timeout_handler)
   signal.alarm(2)
   
   reader.start()
   time.sleep(0.1)
   reader.stop()
   is_test_running = False