<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Readul Hasan Chayan [Heemayl] (Posts about async-await)</title><link>https://heemayl.net/</link><description></description><atom:link href="https://heemayl.net/categories/async-await.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:me@heemayl.net"&gt;Readul Hasan Chayan [Heemayl]&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank"&gt;
&lt;img alt="Creative Commons License BY-NC-SA"
style="border-width:0; margin-top: 10px; margin-bottom: 5px;"
src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"&gt;&lt;/a&gt;
</copyright><lastBuildDate>Thu, 07 Mar 2024 19:03:10 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Async `requests` in Python : Do async I/O on a blocking object</title><link>https://heemayl.net/posts/async-requests-in-python-do-async-io-on-a-blocking-object/</link><dc:creator>Readul Hasan Chayan [Heemayl]</dc:creator><description>&lt;div&gt;&lt;p&gt;After the introduction of the &lt;code&gt;send&lt;/code&gt; method of generators in Python 2.5, it was possible to send values into generators, essentially making them a &lt;em&gt;two-way&lt;/em&gt; object. This leads to the possibility of single-threaded coroutine-based co-operative multitasking. Before 3.5, one could create a coroutine by the &lt;code&gt;asyncio.coroutine&lt;/code&gt; (or &lt;code&gt;types.coroutine&lt;/code&gt;) decorator, and pause a coroutine (when doing I/O) by using &lt;code&gt;yield from&lt;/code&gt; which basically is a syntactic sugar for &lt;code&gt;yield&lt;/code&gt;-ing values from another generator (using a &lt;code&gt;for&lt;/code&gt; loop, for example).&lt;/p&gt;
&lt;p&gt;In Python 3.5, the &lt;code&gt;async&lt;/code&gt;-&lt;code&gt;await&lt;/code&gt; keywords were introduced to support the Async operations natively, with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;async&lt;/code&gt; keyword replaces the need for an explicit decorator to create a coroutine&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;await&lt;/code&gt; is just a syntactic sugar for &lt;code&gt;yield from&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://heemayl.net/posts/async-requests-in-python-do-async-io-on-a-blocking-object/"&gt;Read more…&lt;/a&gt; (3 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>async</category><category>async-await</category><category>concurrent</category><category>io</category><category>python</category><guid>https://heemayl.net/posts/async-requests-in-python-do-async-io-on-a-blocking-object/</guid><pubDate>Wed, 27 Feb 2019 15:35:41 GMT</pubDate></item></channel></rss>