Asyncio -- delayed calculation
Steve D'Aprano
steve+python at pearwood.info
Tue Nov 29 18:30:52 EST 2016
On Wed, 30 Nov 2016 05:41 am, Ian Kelly wrote:
> You mean how do you create something that can be awaited that doesn't
> await something else in turn? With a Future.
>
> import asyncio
>
> class Awaitable(asyncio.Future):
> def wake_up_later(self):
> asyncio.get_event_loop().call_later(3, self.set_result, 42)
Not to be confused with concurrent.Futures.
https://docs.python.org/3.5/library/concurrent.futures.html
https://docs.python.org/3.5/library/asyncio-task.html#asyncio.Future
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list