Tutorial by Examples: asyncio

probably the most common misconception about asnycio is that it lets you run any task in parallel - sidestepping the GIL (global interpreter lock) and therefore execute blocking jobs in parallel (on separate threads). it does not! asyncio (and libraries that are built to collaborate with asyncio) b...
This example uses the asyncio SSE library: https://github.com/brutasse/asyncio-sse import asyncio import sse class Handler(sse.Handler): @asyncio.coroutine def handle_request(self): yield from asyncio.sleep(2) self.send('foo') yield from asyncio.sleep(2) ...
import asyncio async def hello_world(): print('Hello World') loop = asyncio.get_event_loop() loop.run_until_complete(hello_world()) loop.close()

Page 1 of 1