Beispiel #1
0
 def test_future_wrap_future_cancel(self):
     from uvloop.loop import _wrap_future
     f1 = concurrent.futures.Future()
     f2 = _wrap_future(f1, loop=self.loop)
     f2.cancel()
     test_utils.run_briefly(self.loop)
     self.assertTrue(f1.cancelled())
     self.assertTrue(f2.cancelled())
Beispiel #2
0
 def test_future_wrap_future_cancel(self):
     from uvloop.loop import _wrap_future
     f1 = concurrent.futures.Future()
     f2 = _wrap_future(f1, loop=self.loop)
     f2.cancel()
     test_utils.run_briefly(self.loop)
     self.assertTrue(f1.cancelled())
     self.assertTrue(f2.cancelled())
Beispiel #3
0
def test_future_wrap_future_cancel4(loop, run_briefly):
    from uvloop.loop import _wrap_future
    f1 = concurrent.futures.Future()
    f2 = _wrap_future(f1, loop=loop)
    f2.cancel()
    run_briefly(loop)
    assert f1.cancelled()
    assert f2.cancelled()
Beispiel #4
0
 def test_future_wrap_future_cancel2(self):
     from uvloop.loop import _wrap_future
     f1 = concurrent.futures.Future()
     f2 = _wrap_future(f1, loop=self.loop)
     f1.set_result(42)
     f2.cancel()
     test_utils.run_briefly(self.loop)
     self.assertFalse(f1.cancelled())
     self.assertEqual(f1.result(), 42)
     self.assertTrue(f2.cancelled())
Beispiel #5
0
def test_future_wrap_future_cancel5(loop, run_briefly):
    from uvloop.loop import _wrap_future
    f1 = concurrent.futures.Future()
    f2 = _wrap_future(f1, loop=loop)
    f1.set_result(42)
    f2.cancel()
    run_briefly(loop)
    assert not f1.cancelled()
    assert f1.result() == 42
    assert f2.cancelled()
Beispiel #6
0
 def test_future_wrap_future_cancel2(self):
     from uvloop.loop import _wrap_future
     f1 = concurrent.futures.Future()
     f2 = _wrap_future(f1, loop=self.loop)
     f1.set_result(42)
     f2.cancel()
     test_utils.run_briefly(self.loop)
     self.assertFalse(f1.cancelled())
     self.assertEqual(f1.result(), 42)
     self.assertTrue(f2.cancelled())
Beispiel #7
0
 def test_future_wrap_future(self):
     from uvloop.loop import _wrap_future
     def run(arg):
         return (arg, threading.get_ident())
     ex = concurrent.futures.ThreadPoolExecutor(1)
     f1 = ex.submit(run, 'oi')
     f2 = _wrap_future(f1, loop=self.loop)
     res, ident = self.loop.run_until_complete(f2)
     self.assertIsInstance(f2, asyncio.Future)
     self.assertEqual(res, 'oi')
     self.assertNotEqual(ident, threading.get_ident())
Beispiel #8
0
    def test_future_wrap_future(self):
        from uvloop.loop import _wrap_future

        def run(arg):
            return (arg, threading.get_ident())

        ex = concurrent.futures.ThreadPoolExecutor(1)
        f1 = ex.submit(run, 'oi')
        f2 = _wrap_future(f1, loop=self.loop)
        res, ident = self.loop.run_until_complete(f2)
        self.assertIsInstance(f2, asyncio.Future)
        self.assertEqual(res, 'oi')
        self.assertNotEqual(ident, threading.get_ident())
Beispiel #9
0
def test_future_wrap_future2(loop):
    from uvloop.loop import _wrap_future

    def run(arg):
        return (arg, threading.get_ident())

    ex = concurrent.futures.ThreadPoolExecutor(1)
    f1 = ex.submit(run, 'oi')
    f2 = _wrap_future(f1, loop=loop)
    res, ident = loop.run_until_complete(f2)
    assert asyncio.isfuture(f2)
    assert res == 'oi'
    assert ident != threading.get_ident()
Beispiel #10
0
 def test_future_wrap_future_future(self):
     from uvloop.loop import _wrap_future
     f1 = self.create_future()
     f2 = _wrap_future(f1)
     self.assertIs(f1, f2)
Beispiel #11
0
def test_future_wrap_future_future3(create_future):
    from uvloop.loop import _wrap_future
    f1 = create_future()
    f2 = _wrap_future(f1)
    assert f1 is f2
Beispiel #12
0
 def test_future_wrap_future_future(self):
     from uvloop.loop import _wrap_future
     f1 = self.create_future()
     f2 = _wrap_future(f1)
     self.assertIs(f1, f2)