<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Contextvars on Nalar</title>
    <link>https://nalar.dev/tags/contextvars/</link>
    <description>Recent content in Contextvars on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 02 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/contextvars/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Request-Scoped State in Python with contextvars</title>
      <link>https://nalar.dev/request-scoped-state-in-python-with-contextvars/</link>
      <pubDate>Wed, 02 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/request-scoped-state-in-python-with-contextvars/</guid>
      <description>&lt;p&gt;Applications often need small pieces of context to follow a request through several layers: a request ID, tenant identifier, locale, or tracing field. Passing every value through every function is explicit, but can become noisy when the value is cross-cutting rather than part of the function&amp;rsquo;s business input.&lt;/p&gt;&#xA;&lt;p&gt;Python&amp;rsquo;s &lt;code&gt;contextvars&lt;/code&gt; module provides context-local state designed to work with asynchronous code.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-a-normal-global-is-unsafe&#34;&gt;Why a normal global is unsafe&lt;/h2&gt;&#xA;&lt;p&gt;A module-level variable is shared by all concurrent requests:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
