<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Queues on Nalar</title>
    <link>https://nalar.dev/tags/queues/</link>
    <description>Recent content in Queues on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 09 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/queues/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Shut Down asyncio Worker Queues Cleanly</title>
      <link>https://nalar.dev/shut-down-asyncio-worker-queues-cleanly/</link>
      <pubDate>Wed, 09 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/shut-down-asyncio-worker-queues-cleanly/</guid>
      <description>&lt;p&gt;Asynchronous worker pools often start with a simple pattern: producers put jobs into an &lt;code&gt;asyncio.Queue&lt;/code&gt;, consumers loop over &lt;code&gt;get()&lt;/code&gt;, and the application waits for &lt;code&gt;join()&lt;/code&gt; before exiting.&lt;/p&gt;&#xA;&lt;p&gt;The awkward part is shutdown. Older designs commonly put one sentinel value into the queue for each worker, cancel consumers after &lt;code&gt;join()&lt;/code&gt;, or maintain a separate stop event. Each approach can work, but each adds a second protocol beside the queue itself.&lt;/p&gt;&#xA;&lt;p&gt;Python 3.13 added &lt;code&gt;asyncio.Queue.shutdown()&lt;/code&gt; and the &lt;code&gt;asyncio.QueueShutDown&lt;/code&gt; exception. They let the queue represent its own lifecycle: open for producers, shutting down while existing work drains, and finally closed to consumers.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
