Difference between revisions of "Await"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
[[wikipedia:Await]] | [[wikipedia:Await]] | ||
+ | |||
+ | == In Python == | ||
+ | [[Python 3.5]] has added support for async/await as described in PEP 492 (https://www.python.org/dev/peps/pep-0492/). | ||
+ | |||
+ | <syntaxhighlight lang="python"> | ||
+ | import asyncio | ||
+ | |||
+ | async def main(): | ||
+ | print("hello") | ||
+ | await asyncio.sleep(1) | ||
+ | print("world") | ||
+ | |||
+ | asyncio.run(main()) | ||
+ | </syntaxhighlight> | ||
Revision as of 11:20, 10 August 2021
In Python
Python 3.5 has added support for async/await as described in PEP 492 (https://www.python.org/dev/peps/pep-0492/).
<syntaxhighlight lang="python"> import asyncio
async def main():
print("hello") await asyncio.sleep(1) print("world")
asyncio.run(main()) </syntaxhighlight>
See also
- Programming: C, Python,
go
,loop
,while
,for
,if
,variable
, Error handling, Regex, Function, IDE, await, R (programming language), XACML, Type, Class inheritance, Methods, Scheme, Array, Deserialization
Advertising: