Skip to content

Commit 177087a

Browse files
committed
run_until_complete returns coro return value.
1 parent 9fbcb73 commit 177087a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

FASTPOLL.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ This version has the following features:
1818
is called with a generator function
1919
[PR292](https://github.com/micropython/micropython-lib/pull/292). This traps
2020
a common coding error which otherwise results in silent failure.
21-
* The version and the presence of an event loop instance can be tested at
22-
runtime.
21+
* The presence of the `fast_io` version can be tested at runtime.
22+
* The presence of an event loop instance can be tested at runtime.
23+
* `run_until_complete(coro())` now returns the value returned by `coro()` as
24+
per CPython
25+
[micropython-lib PR270](https://github.com/micropython/micropython-lib/pull/270).
2326

2427
Note that priority device drivers are written by using the officially supported
25-
technique for writing stream I/O drivers. If official `uasyncio` acquires a
26-
means of prioritising I/O other than that in this version, application code
27-
changes should be minimal. Using the fast I/O mechanism in this version
28-
requires changing just one line of code compared to running under the official
29-
version.
28+
technique for writing stream I/O drivers. Code using such drivers will run
29+
unchanged under the `fast_io` version. Using the fast I/O mechanism requires
30+
adding just one line of code. This implies that if official `uasyncio` acquires
31+
a means of prioritising I/O other than that in this version, application code
32+
changes should be minimal.
3033

3134
The high priority mechanism formerly provided in `asyncio_priority.py` was a
3235
workround based on the view that stream I/O written in Python would remain

fast_io/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ def run_forever(self):
264264
def run_until_complete(self, coro):
265265
assert not isinstance(coro, type_genf), 'Coroutine arg expected.' # upy issue #3241
266266
def _run_and_stop():
267-
yield from coro
268-
yield StopLoop(0)
267+
ret = yield from coro # https://github.com/micropython/micropython-lib/pull/270
268+
yield StopLoop(ret)
269269
self.call_soon(_run_and_stop())
270-
self.run_forever()
270+
return self.run_forever()
271271

272272
def stop(self):
273273
self.call_soon((lambda: (yield StopLoop(0)))())

0 commit comments

Comments
 (0)