Strawman proposal for a flexible primitive to wait for one of a set of Futures.
This commit is contained in:
parent
2377e8f715
commit
209036b898
17
pep-3156.txt
17
pep-3156.txt
|
@ -536,7 +536,7 @@ Transports have the following public methods:
|
|||
- ``writelines(iterable)``. Equivalent to::
|
||||
|
||||
for data in iterable:
|
||||
self.write(data)
|
||||
self.write(data)
|
||||
|
||||
- ``write_eof()``. Close the writing end of the connection.
|
||||
Subsequent calls to ``write()`` are not allowed. Once all buffered
|
||||
|
@ -838,10 +838,10 @@ Open Issues
|
|||
caller (likely a transport) must then write code like this::
|
||||
|
||||
try:
|
||||
res = ev.sock_recv(sock, 8192)
|
||||
res = ev.sock_recv(sock, 8192)
|
||||
except Future as f:
|
||||
yield from sch.block_future(f)
|
||||
res = f.result()
|
||||
yield from sch.block_future(f)
|
||||
res = f.result()
|
||||
|
||||
- Do we need a larger vocabulary of operations for combining
|
||||
coroutines and/or futures? E.g. in addition to par() we could have
|
||||
|
@ -852,6 +852,15 @@ Open Issues
|
|||
syntax). Anyway, I think all of these are easy enough to write
|
||||
using ``Task``.
|
||||
|
||||
Proposal: ``f = yield from wait_one(fs)`` takes a set of Futures and
|
||||
sets f to the first of those that is done. (Yes, this requires an
|
||||
intermediate Future to wait for.) You can then write::
|
||||
|
||||
while fs:
|
||||
f = tulip.wait_one(fs)
|
||||
fs.remove(f)
|
||||
<inspect f>
|
||||
|
||||
- Task or callback priorities? (I hope not.)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue