You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
351 B
Python

### asyncio.Future, аналог concurrent.futures.Future
import asyncio
async def slow_operation(future):
await asyncio.sleep(1)
future.set_result("Future is done!")
loop = asyncio.get_event_loop()
future = asyncio.Future()
asyncio.ensure_future(slow_operation(future))
loop.run_until_complete(future)
print(future.result())
loop.close()