Skip to content

Commit a62541a

Browse files
committed
Add loop.create_future() method (will be available in Python 3.5.2)
1 parent f3d6dc7 commit a62541a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/test_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ def test_cython_coro_is_coroutine(self):
426426
_format_coroutine(coro) # This line checks against Cython segfault
427427
coro.close()
428428

429+
def test_loop_create_future(self):
430+
fut = self.loop.create_future()
431+
self.assertTrue(isinstance(fut, asyncio.Future))
432+
self.assertIs(fut._loop, self.loop)
433+
fut.cancel()
434+
429435

430436
class TestBaseAIO(_TestBase, AIOTestCase):
431437
pass

uvloop/loop.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,10 @@ cdef class Loop:
946946
"""Returns True if the event loop was closed."""
947947
return bool(self._closed)
948948

949+
def create_future(self):
950+
"""Create a Future object attached to the loop."""
951+
return self._new_future()
952+
949953
def create_task(self, coro):
950954
"""Schedule a coroutine object.
951955

0 commit comments

Comments
 (0)