<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>debugging &amp;mdash; sandeepk</title>
    <link>https://blogs.dgplug.org/sandeepk/tag:debugging</link>
    <description></description>
    <pubDate>Sun, 19 Apr 2026 06:09:42 +0000</pubDate>
    <item>
      <title>Debugging maxlocksper_transaction: A Journey into Pytest Parallelism</title>
      <link>https://blogs.dgplug.org/sandeepk/debugging-max_locks_per_transaction-a-journey-into-pytest-parallelism</link>
      <description>&lt;![CDATA[So I was fixing some slow tests, and whenever I ran them through the pytest command, I was greeted with the dreaded maxlockspertransaction error.&#xA;&#xA;My first instinct? Just crank up the maxlockspertransaction from 64 to 1024.&#xA;&#xA;But... that didn’t feel right. I recreate my DB frequently, which means I’d have to set that value again and again. It felt like a hacky workaround rather than a proper solution.&#xA;&#xA;Then, like any developer, I started digging around — first checking the Confluence page for dev docs to see if anyone else had faced this issue. No luck. Then I moved to Slack, and that’s where I found this command someone had shared:&#xA;&#xA;pytest -n=0&#xA;&#xA;This was new to me. So, like any sane dev in 2025, I asked ChatGPT what this was about. That’s how I came across pytest-xdist.&#xA;&#xA;What is pytest-xdist?&#xA;&#xA;  The pytest-xdist plugin extends pytest with new test execution modes — the most common one is distributing tests across multiple CPUs to speed up test execution.&#xA;&#xA;What does pytest-xdist do?&#xA;&#xA;  Runs tests in parallel using numprocesses workers (Python processes), which is a game changer when:&#xA;  - You have a large test suite  &#xA;  - Each test takes a significant amount of time  &#xA;  - Your tests are independent (i.e., no shared global state)&#xA;&#xA;---&#xA;&#xA;That’s pretty much it — I plugged in pytest -n=0 and boom, no more transaction locks errors.  &#xA;&#xA;Cheers!&#xA;&#xA;References&#xA;https://pytest-xdist.readthedocs.io/en/stable/&#xA;https://docs.pytest.org/en/stable/reference/reference.html&#xA;&#xA;#pytest #Python #chatgpt #debugging&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>So I was fixing some slow tests, and whenever I ran them through the <code>pytest</code> command, I was greeted with the dreaded <code>max_locks_per_transaction</code> error.</p>

<p>My first instinct? Just crank up the <code>max_locks_per_transaction</code> from 64 to 1024.</p>

<p>But... that didn’t feel right. I recreate my DB frequently, which means I’d have to set that value again and again. It felt like a hacky workaround rather than a proper solution.</p>

<p>Then, like any developer, I started digging around — first checking the Confluence page for dev docs to see if anyone else had faced this issue. No luck. Then I moved to Slack, and that’s where I found this command someone had shared:</p>

<pre><code class="language-bash">pytest -n=0
</code></pre>

<p>This was new to me. So, like any sane dev in 2025, I asked ChatGPT what this was about. That’s how I came across <code>pytest-xdist</code>.</p>

<h2 id="what-is-pytest-xdist">What is <code>pytest-xdist</code>?</h2>

<blockquote><p>The <code>pytest-xdist</code> plugin extends pytest with new test execution modes — the most common one is distributing tests across multiple CPUs to <strong>speed up test execution</strong>.</p></blockquote>

<h2 id="what-does-pytest-xdist-do">What does <code>pytest-xdist</code> do?</h2>

<blockquote><p>Runs tests in <strong>parallel</strong> using <code>&lt;numprocesses&gt;</code> workers (Python processes), which is a game changer when:
– You have a large test suite<br>
– Each test takes a significant amount of time<br>
– Your tests are independent (i.e., no shared global state)</p></blockquote>

<hr>

<p>That’s pretty much it — I plugged in <code>pytest -n=0</code> and boom, no more transaction locks errors.</p>

<p>Cheers!</p>

<p>References
– <a href="https://pytest-xdist.readthedocs.io/en/stable/" rel="nofollow">https://pytest-xdist.readthedocs.io/en/stable/</a>
– <a href="https://docs.pytest.org/en/stable/reference/reference.html" rel="nofollow">https://docs.pytest.org/en/stable/reference/reference.html</a></p>

<p><a href="/sandeepk/tag:pytest" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">pytest</span></a> <a href="/sandeepk/tag:Python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python</span></a> <a href="/sandeepk/tag:chatgpt" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">chatgpt</span></a> <a href="/sandeepk/tag:debugging" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">debugging</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/debugging-max_locks_per_transaction-a-journey-into-pytest-parallelism</guid>
      <pubDate>Wed, 16 Jul 2025 17:07:59 +0000</pubDate>
    </item>
  </channel>
</rss>