Example #1
0
 def glet():
     try:
         greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)
     except Exception, exc:
         excs.append(exc)
         return
Example #2
0
 def test_pause_until(self):
     until = time.time() + TESTING_TIMEOUT
     greenhouse.pause_until(until)
     assert until + 0.03 > time.time() >= until
Example #3
0
        @greenhouse.schedule
        @greenhouse.greenlet
        def glet():
            try:
                greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)
            except Exception, exc:
                excs.append(exc)
                return
            l[0] = True

        greenhouse.pause()
        greenhouse.schedule_exception_at(
                time.time() + TESTING_TIMEOUT, self.CustomError(), glet)

        greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)

        assert not l[0]
        assert isinstance(excs[0], self.CustomError), excs

    def test_schedule_exception_at_rejects_funcs(self):
        def f(): pass
        self.assertRaises(
                TypeError, greenhouse.schedule_exception_at,
                time.time() + 1, Exception(), f)

    def test_schedule_exception_at_rejects_dead_glets(self):
        @greenhouse.schedule
        @greenhouse.greenlet
        def g():
            pass
Example #4
0
 def glet():
     try:
         greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)
     except Exception, exc:
         excs.append(exc)
         return
Example #5
0
 def test_pause_until(self):
     until = time.time() + TESTING_TIMEOUT
     greenhouse.pause_until(until)
     assert until + 0.03 > time.time() >= until
Example #6
0
        @greenhouse.schedule
        @greenhouse.greenlet
        def glet():
            try:
                greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)
            except Exception, exc:
                excs.append(exc)
                return
            l[0] = True

        greenhouse.pause()
        greenhouse.schedule_exception_at(
                time.time() + TESTING_TIMEOUT, self.CustomError(), glet)

        greenhouse.pause_until(time.time() + TESTING_TIMEOUT * 2)

        assert not l[0]
        assert isinstance(excs[0], self.CustomError), excs

    def test_schedule_exception_at_rejects_funcs(self):
        def f(): pass
        self.assertRaises(
                TypeError, greenhouse.schedule_exception_at,
                time.time() + 1, Exception(), f)

    def test_schedule_exception_at_rejects_dead_glets(self):
        @greenhouse.schedule
        @greenhouse.greenlet
        def g():
            pass