summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-03 00:21:17 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-12-03 00:21:17 +0100
commit3e99c1b0b5e7921abde1cdb7d1450a30a7157794 (patch)
tree0f776311ed5acacd4fc5f8553ab336c464311716
parent24cbd1f6817040ad6a8e8b7375c8eb0f5ec23f1f (diff)
downloadaioeventlet-3e99c1b0b5e7921abde1cdb7d1450a30a7157794.tar.gz
Rename the link_future() function to yield_future()
Set also the version to 0.4
-rw-r--r--aiogreen.py7
-rw-r--r--doc/changelog.rst5
-rw-r--r--doc/conf.py4
-rw-r--r--doc/index.rst2
-rw-r--r--doc/using.rst8
-rw-r--r--setup.py2
-rw-r--r--tests/test_eventlet.py30
7 files changed, 33 insertions, 25 deletions
diff --git a/aiogreen.py b/aiogreen.py
index 93a4ec1..31e53eb 100644
--- a/aiogreen.py
+++ b/aiogreen.py
@@ -306,9 +306,12 @@ def wrap_greenthread(gt, loop=None):
return fut
-def link_future(future, loop=None):
+def yield_future(future, loop=None):
"""Wait for a future, a task, or a coroutine object from a greenthread.
+ Yield control other eligible eventlet coroutines until the future is done
+ (finished successfully or failed with an exception).
+
Return the result or raise the exception of the future.
The function must not be called from the greenthread
@@ -316,7 +319,7 @@ def link_future(future, loop=None):
"""
future = asyncio.async(future, loop=loop)
if future._loop._greenthread == eventlet.getcurrent():
- raise RuntimeError("link_future() must not be called from "
+ raise RuntimeError("yield_future() must not be called from "
"the greenthread of the aiogreen event loop")
event = eventlet.event.Event()
diff --git a/doc/changelog.rst b/doc/changelog.rst
index 87f368e..9c1e98f 100644
--- a/doc/changelog.rst
+++ b/doc/changelog.rst
@@ -1,6 +1,11 @@
Changelog
=========
+Version 0.4
+-----------
+
+* Rename the ``link_future()`` function to :func:`yield_future`
+
2014-10-23: version 0.3
-----------------------
diff --git a/doc/conf.py b/doc/conf.py
index 752f97b..a5bf6dc 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -51,9 +51,9 @@ copyright = u'2014, Victor Stinner'
# built documents.
#
# The short X.Y version.
-version = '0.3'
+version = '0.4'
# The full version, including alpha/beta/rc tags.
-release = '0.3'
+release = '0.4'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/index.rst b/doc/index.rst
index fc36426..50037d8 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -11,7 +11,7 @@ aiogreen implements the asyncio API (`PEP 3156
possible to write asyncio code in a project currently written for eventlet.
aiogreen allows to use greenthreads in asyncio coroutines, and to use asyncio
-coroutines, tasks and futures in greenthreads: see :func:`link_future` and
+coroutines, tasks and futures in greenthreads: see :func:`yield_future` and
:func:`wrap_greenthread` functions.
The main visible difference between aiogreen and trollius is the behaviour of
diff --git a/doc/using.rst b/doc/using.rst
index 810af1b..ed82f1a 100644
--- a/doc/using.rst
+++ b/doc/using.rst
@@ -126,10 +126,10 @@ aiogreen specific functions:
.. warning::
aiogreen API is not considered as stable yet.
-link_future
------------
+yield_future
+------------
-.. function:: link_future(future, loop=None)
+.. function:: yield_future(future, loop=None)
Wait for a future, a task, or a coroutine object from a greenthread.
@@ -166,7 +166,7 @@ link_future
task = asyncio.async(coro_slow_sum(1, 2))
- value = aiogreen.link_future(task)
+ value = aiogreen.yield_future(task)
print("1 + 2 = %s" % value)
loop.stop()
diff --git a/setup.py b/setup.py
index b2d0f88..0fc1d5b 100644
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,7 @@ with open("README") as fp:
install_options = {
"name": "aiogreen",
- "version": "0.3",
+ "version": "0.4",
"license": "Apache License 2.0",
"author": 'Victor Stinner',
"author_email": 'victor.stinner@gmail.com',
diff --git a/tests/test_eventlet.py b/tests/test_eventlet.py
index 2f5d5c6..fbb347f 100644
--- a/tests/test_eventlet.py
+++ b/tests/test_eventlet.py
@@ -88,16 +88,16 @@ except ImportError:
raise ValueError("error")
-def greenthread_link_future(result, loop):
+def greenthread_yield_future(result, loop):
try:
- value = aiogreen.link_future(coro_slow_append(result, 1, 0.020))
+ value = aiogreen.yield_future(coro_slow_append(result, 1, 0.020))
result.append(value)
- value = aiogreen.link_future(coro_slow_append(result, 2, 0.010))
+ value = aiogreen.yield_future(coro_slow_append(result, 2, 0.010))
result.append(value)
try:
- value = aiogreen.link_future(coro_slow_error())
+ value = aiogreen.yield_future(coro_slow_error())
except ValueError as exc:
result.append(str(exc))
@@ -163,10 +163,10 @@ class EventletTests(tests.TestCase):
class LinkFutureTests(tests.TestCase):
- def test_greenthread_link_future(self):
+ def test_greenthread_yield_future(self):
result = []
self.loop.call_soon(eventlet.spawn,
- greenthread_link_future, result, self.loop)
+ greenthread_yield_future, result, self.loop)
self.loop.run_forever()
self.assertEqual(result, [1, 10, 2, 20, 'error', 4])
@@ -174,7 +174,7 @@ class LinkFutureTests(tests.TestCase):
result = []
def func(fut):
- value = aiogreen.link_future(coro_slow_append(result, 3))
+ value = aiogreen.yield_future(coro_slow_append(result, 3))
result.append(value)
self.loop.stop()
@@ -183,12 +183,12 @@ class LinkFutureTests(tests.TestCase):
self.loop.run_forever()
self.assertEqual(result, [3, 30])
- def test_link_future_not_running(self):
+ def test_yield_future_not_running(self):
result = []
def func(event, fut):
event.send('link')
- value = aiogreen.link_future(fut)
+ value = aiogreen.yield_future(fut)
result.append(value)
self.loop.stop()
@@ -201,12 +201,12 @@ class LinkFutureTests(tests.TestCase):
self.loop.run_forever()
self.assertEqual(result, [21])
- def test_link_future_from_loop(self):
+ def test_yield_future_from_loop(self):
result = []
def func(fut):
try:
- value = aiogreen.link_future(fut)
+ value = aiogreen.yield_future(fut)
except Exception as exc:
result.append('error')
else:
@@ -219,9 +219,9 @@ class LinkFutureTests(tests.TestCase):
self.loop.run_forever()
self.assertEqual(result, ['error'])
- def test_link_future_invalid_type(self):
+ def test_yield_future_invalid_type(self):
def func(obj):
- return aiogreen.link_future(obj)
+ return aiogreen.yield_future(obj)
@asyncio.coroutine
def coro_func():
@@ -236,14 +236,14 @@ class LinkFutureTests(tests.TestCase):
with tests.mock.patch('traceback.print_exception') as m_print:
self.assertRaises(TypeError, gt.wait)
- def test_link_future_wrong_loop(self):
+ def test_yield_future_wrong_loop(self):
result = []
loop2 = asyncio.new_event_loop()
self.addCleanup(loop2.close)
def func(fut):
try:
- value = aiogreen.link_future(fut, loop=loop2)
+ value = aiogreen.yield_future(fut, loop=loop2)
except Exception as exc:
result.append(str(exc))
else: