Beispiel #1
0
    def test_exception(self):
        future1 = BaseFuture()
        future2 = BaseFuture()

        ev = AsyncEventLoop()
        with ev:
            any_future = AnyFuture(future1, future2)
            future1.set_exception(RuntimeError())

        ev.execute_all_tasks()
        self.assertEqual(type(any_future.exception()), RuntimeError)
Beispiel #2
0
    def test_simple(self):
        future1 = BaseFuture()
        future2 = BaseFuture()

        ev = AsyncEventLoop()
        with ev:
            any_future = AnyFuture(future1, future2)
            future2.set_result(3)

        ev.execute_all_tasks()
        self.assertEqual(any_future.result(), 3)
        self.assertFalse(future1.done())
Beispiel #3
0
 def main():
     count()
     try:
         fut1, fut2 = raises(), raises()
         yield AnyFuture(fut1, fut2)
     except RuntimeError:
         yield count()
         try:
             yield fut1
         except RuntimeError:
             yield count()
Beispiel #4
0
 def main():
     results = yield AnyFuture()
     return_(results)
Beispiel #5
0
 def main():
     yield AnyFuture(raises(), count())