В своём докладе я постараюсь ответить на следующие вопросы:
* Какие мотивы стояли за созданием библиотеки asyncio?
* Как в ней реализовано асинхронное выполнение кода?
* Почему это полезно знать, если пишешь код с её использованием?
Traceback (most recent call last): File "base_loop.py", line 42, in <module> loop.run_until_complete(main, loop) File "base_loop.py", line 17, in run_until_complete callback(*args) File "base_loop.py", line 29, in maybe_print raise Exception(msg) Exception: Noooooooo!!!
self.coro.send(None) else: self.coro.throw(exc) except StopIteration: result = None except Exception as exc: self.set_exception(exc) else: if isinstance(result, Future): result.add_done_callback(self.wakeup) elif result is None: self.loop.call_soon(self.step)
self.coro.send(None) else: self.coro.throw(exc) except StopIteration: result = None except Exception as exc: self.set_exception(exc) else: if isinstance(result, Future): result.add_done_callback(self.wakeup) elif result is None: self.loop.call_soon(self.step)
if self.exception is not None: raise self.exception return self._result def __await__(self): if self.state == 'PENDING': yield self return self.result()
self.coro.send(None) else: self.coro.throw(exc) except StopIteration: result = None except Exception as exc: self.set_exception(exc) else: if isinstance(result, Future): result.add_done_callback(self.wakeup) elif result is None: self.loop.call_soon(self.step)
if self.exception is not None: raise self.exception return self._result def __await__(self): if self.state == 'PENDING': yield self return self.result()
post-async/await world by Nathaniel J. Smith 2. Playing with asyncio by Nathan Hoad 3. I don't understand Python's Asyncio by Armin Ronacher 4. The report of our death by Glyph Lefkowitz 5. Trio: Async concurrency for mere mortals by Nathaniel J. Smith 6. Fear and Awaiting in Async: A Savage Journey to the Heart of the Coroutine Dream by David Beazley 7. Die Threads by David Beazley 8. Asyncio сегодня и завтра by Юрий Селиванов 9. Подводные камни asyncio by Андрей Светлов 10. Разница между yield и yield from by Guido van Rossum 11. uvloop: Blazing fast python networking by Юрий Селиванов