<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aaron Rose on Medium]]></title>
        <description><![CDATA[Stories by Aaron Rose on Medium]]></description>
        <link>https://medium.com/@aaron.rose.tx?source=rss-392ce918ae14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sxSIbQU5T64YSqDSEts1ag.png</url>
            <title>Stories by Aaron Rose on Medium</title>
            <link>https://medium.com/@aaron.rose.tx?source=rss-392ce918ae14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:43:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aaron.rose.tx/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Secret Life of Azure: Canary Deployments for LLMs]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-azure-canary-deployments-for-llms-7d0fba1ee178?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d0fba1ee178</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Sat, 02 May 2026 18:37:22 GMT</pubDate>
            <atom:updated>2026-05-02T18:37:22.012Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tJ7JwPjlpBIYkQLesUTAoA.jpeg" /></figure><p><em>Rolling out models safely with Similarity Scoring and Graduation Thresholds</em></p><p>#AzureAI #CanaryDeployment #Guardrails #ModelDrift</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 40</em></p><p>The library was at peak capacity, and for weeks, the scarlet <strong>Guardrails</strong> had been silent. But Timothy noticed something subtle in the logs — a “vibe shift.” The responses weren’t wrong, but they were becoming shorter, more clinical, and lacked the helpful “Librarian” warmth they once had.</p><p>“Margaret,” Timothy said, “nothing is broken, but something is <em>fading</em>. The model we updated last night passed all the unit tests, but the readers are starting to complain that the soul of the library feels… different. It’s like a slow gas leak that doesn’t trigger the fire alarm.”</p><p>Margaret picked up a sharp <strong>Cobalt Blue marker</strong> and drew a small birdcage at the entrance of the library.</p><p>“That’s <strong>Semantic Drift</strong>, Timothy,” Margaret said. “Standard tests catch the crashes, but they miss the decay. To protect the library’s standards, we need <strong>The Canary</strong>. We move from ‘Hopeful Deployment’ to <strong>Traffic-Shifting Validation</strong>.”</p><h3>The Cobalt Shield: Canary Deployments</h3><p>“How do we test a soul?” Timothy asked.</p><p>“We don’t test it on everyone at once,” Margaret explained. She drew two paths: one wide and one very narrow. “We use a <strong>Canary Deployment</strong>. When we have a new version of the model, we only send 5% of the traffic to it — the ‘Canaries.’ We monitor their interactions in real-time. If the new version starts behaving oddly, we kill the connection before the other 95% of the library even knows there was a change.”</p><h3>The Drift Meter: Gold Standards &amp; Sampling</h3><p>“But how do we measure ‘oddly’ if the answer is technically correct?” Timothy pointed out. “And won’t comparing every answer slow us down?”</p><p>“We use a <strong>Gold Standard Archive</strong>,” Margaret said, drawing a small vault. “We curate a baseline of our highest-quality historical interactions. We don’t measure every breath; we <strong>sample</strong>. The similarity scoring runs <strong>asynchronously</strong> — the user never waits for the score, but the system calculates it a second later. If the mathematical ‘distance’ between the Canary’s output and the Gold Standard grows, the bird stops singing.”</p><h3>The Graduation: Time and Thresholds</h3><p>“How long does the Canary have to survive before we trust it?” Timothy asked.</p><p>Margaret drew a timer. “<strong>24 hours and 10,000 successful requests.</strong> That’s our graduation threshold. If the Canary stays green that long, we shift traffic incrementally — 5% to 25% to 100%. Trust, but verify. Then trust a little more.”</p><h3>The Emergency Brake: Automated Rollback</h3><p>“What if the rollback itself fails?” Timothy questioned. “What if the cobalt lever jams?”</p><p>Margaret drew a second, heavier lever. “Then we pull the <strong>Emergency Brake</strong> — a circuit breaker that defaults to a safe static response: <em>‘The library is temporarily experiencing high volume.’</em> It’s not ideal, but the worst outage is the one where the system lies about being fine. In the Cobalt Arc, we favor a quiet ‘Closed’ sign over a broken ‘Open’ sign.”</p><h3>The Result</h3><p>Timothy watched the dashboard as a new update rolled out. A few minutes in, the “Similarity Score” on the 5% slice began to dip into the red. Before Timothy could even reach for his mouse, the cobalt lever flickered. The traffic shifted back to the previous version instantly. The “Librarian’s Voice” remained intact for the public.</p><p>“The readers didn’t even notice,” Timothy said, exhaling.</p><p>Margaret capped the cobalt marker. “That is the <strong>Canary</strong>, Timothy. Reliability isn’t about never making a mistake — it’s about making sure your mistakes stay small, quiet, and far away from the front desk.”</p><h3>The Core Concepts</h3><ul><li><strong>Canary Deployment:</strong> Testing a new model on a small traffic slice (5%) before a full rollout.</li><li><strong>Semantic Drift:</strong> The qualitative decay of model output that bypasses traditional pass/fail logic.</li><li><strong>Gold Standard Archive:</strong> A curated dataset of high-quality historical responses used for similarity comparison.</li><li><strong>Graduation Threshold:</strong> Pre-defined metrics (time/volume) that a Canary must meet to progress to full deployment.</li><li><strong>Emergency Brake:</strong> A fail-safe “Circuit Breaker” that provides a static fallback if an automated rollback fails.</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d0fba1ee178" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of JavaScript: The Sandbox]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-javascript-the-sandbox-d95164681ecd?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/d95164681ecd</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Sat, 02 May 2026 06:52:07 GMT</pubDate>
            <atom:updated>2026-05-02T06:52:07.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnXAqE1G8OTGT64o9ePaaw.jpeg" /></figure><p><em>Escaping the walled garden with the File System Access API</em></p><p>#JavaScript #WebPerformance #Frontend #FileSystemAPI</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 34</em></p><h3>The Cluttered Folder</h3><p>Timothy opened his local Downloads folder and sighed. The directory was a complete mess, filled with a massive list of almost identical text files: diagnostic-log.txt, diagnostic-log (1).txt, diagnostic-log (2).txt, all the way down to (14).txt.</p><p>“The export feature is working, but the developer experience is terrible,” Timothy explained to Margaret as she walked up with her dark roast coffee. “Every time the user clicks ‘Export Logs’, the browser generates a Blob and forces an &lt;a download&gt; click. If they update the log and export it again ten minutes later, the browser just downloads a brand new copy.&quot;</p><h3>The Walled Garden</h3><p>Margaret looked at the messy directory. “Why don’t you just overwrite the original file when they click save the second time?”</p><p>“I can’t,” Timothy said, shaking his head. “The browser is a walled garden. It doesn’t have access to the operating system’s native file system for security reasons. Every time I trigger a download, the browser treats it as a completely isolated, brand new event.”</p><p>“Is it still a walled garden?” Margaret asked, taking a sip of her coffee. “Or have you just stopped checking the gates?”</p><p>Timothy frowned. “What do you mean?”</p><p>“The &lt;a download&gt; attribute was a great hack for 2014,&quot; Margaret explained. &quot;But you are treating the browser like a simple document viewer. What if we treated it like a native desktop application?&quot;</p><h3>The File Handle</h3><p>Margaret picked up a dry-erase marker and stepped to the whiteboard. She wrote showSaveFilePicker().</p><p>“Welcome to the File System Access API,” Margaret said. “Instead of blindly throwing files over the browser wall into the Downloads folder, we can explicitly ask the user for permission to access a specific file on their hard drive. Once they grant us permission, the operating system hands the JavaScript engine a persistent file handle.”</p><p>“And once we have the handle?” Timothy asked.</p><p>“Then the wall comes down,” Margaret smiled. “We can open a writable stream and write data directly to that exact file on their local disk. No more (1).txt duplicates.&quot;</p><h3>The Feature Detection</h3><p>“This sounds incredible,” Timothy said. “But what if a user is on Safari or Firefox? Do they support it yet?”</p><p>“That is the reality of the bleeding edge,” Margaret noted. “The File System Access API is currently supported in Chromium-based browsers like Chrome and Edge. For the rest, the wall is still firmly up.”</p><p>“So the application just breaks for them?” Timothy asked.</p><p>“Only if you don’t check the gates first,” Margaret corrected. “You use feature detection. If the browser supports the modern API, you use the file handle. If it doesn’t, you gracefully fall back to the legacy download pattern.”</p><h3>The Writable Stream</h3><p>Timothy completely scrapped his legacy download logic. Following Margaret’s guidance, he tapped into the window object to check for feature support, invoking the file picker when available, and leveraging the streaming architecture he had been mastering all week to pipe the data straight to the disk.</p><pre>// main.js - Writing Directly to the Local File System<br>async function saveDiagnosticLog(logText) {<br>  // 1. Feature Detection: Check if the modern API is supported<br>  if (&#39;showSaveFilePicker&#39; in window) {<br>    try {<br>      // 2. Prompt the user to select or create a file<br>      const fileHandle = await window.showSaveFilePicker({<br>        suggestedName: &#39;diagnostic-log.txt&#39;,<br>        types: [{<br>          description: &#39;Text Files&#39;,<br>          accept: { &#39;text/plain&#39;: [&#39;.txt&#39;] },<br>        }],<br>      });<br><br>      // 3. Request a writable stream to that specific local file<br>      const writableStream = await fileHandle.createWritable();<br><br>      // 4. Write the payload directly to the hard drive<br>      await writableStream.write(logText);<br>      <br>      // 5. Close the stream to release the file lock<br>      await writableStream.close();<br><br>    } catch (error) {<br>      // Safely catch AbortErrors if the user clicks &quot;Cancel&quot; in the native dialog<br>      console.error(&#39;File save cancelled or failed:&#39;, error);<br>    }<br>  } else {<br>    // 6. Fallback: Use the legacy &lt;a download&gt; pattern for Safari/Firefox<br>    const blob = new Blob([logText], { type: &#39;text/plain&#39; });<br>    const url = URL.createObjectURL(blob);<br>    const a = document.createElement(&#39;a&#39;);<br>    a.href = url;<br>    a.download = &#39;diagnostic-log.txt&#39;;<br>    a.click();<br>    URL.revokeObjectURL(url);<br>  }<br>}</pre><p>Timothy refreshed the dashboard and clicked the export button. Instead of a silent download, a native Windows save dialog appeared. He selected his documents folder and saved the file.</p><p>Ten minutes later, the log data updated on the screen. He clicked export again. This time, there was no prompt, and no duplicate file was created. The JavaScript engine securely streamed the new data directly into the exact same file handle, cleanly overwriting the contents.</p><p>By utilizing the File System Access API and respecting feature detection, Timothy bridged the gap between the web application and the operating system, bringing true native IDE capabilities straight to the browser without breaking older clients.</p><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d95164681ecd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of AWS: Multi-Region Failover]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-aws-multi-region-failover-30474a0e2de5?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/30474a0e2de5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Fri, 01 May 2026 13:08:40 GMT</pubDate>
            <atom:updated>2026-05-01T13:08:40.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BY_tKvbyPJEEVSKPYZMY1w.jpeg" /></figure><p><em>How to survive a complete AWS region outage with DynamoDB Global Tables and Route 53</em></p><p>#AWS #DynamoDB #Route53 #DisasterRecovery</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 70</em></p><p>Timothy was leaning back in his chair, sipping his coffee with an undeniable air of satisfaction. He looked around the grand Victorian studio. His architecture was decoupled. His API limits were protected. His secrets were locked in a vault, and his Dead-Letter Queues were standing by as a safety net.</p><p>“It is bulletproof, Margaret,” Timothy said as she walked in. “Even if the third-party payment vendor goes offline for a month, we will not lose a single byte of data. The system is invincible.”</p><p>“It is an impressive single-region architecture,” Margaret agreed, taking her usual seat. “We have come a long way from writing your very first Lambda function. But what happens if us-east-1 goes down?&quot;</p><p>Timothy laughed. “The primary AWS data center in Northern Virginia? It never goes down.”</p><p>Margaret just looked at him, raising a single eyebrow in a silent challenge.</p><p>Timothy’s smile slowly faded. “Okay, historically speaking, when us-east-1 experiences a massive outage, half the internet goes down with it. If that happens, our API Gateway, our Lambda functions, and our DynamoDB tables are completely offline. The safety nets will not matter if the building they are in is on fire.&quot;</p><p>“Exactly,” Margaret said. “To achieve true enterprise-grade resilience, your architecture cannot exist in just one physical location. You have to span the continent. We need to implement <strong>Multi-Region Failover</strong> using <strong>DynamoDB Global Tables</strong> and <strong>Amazon Route 53</strong>.”</p><h3>DynamoDB Global Table for Replication</h3><p>“The hardest part of a multi-region strategy is not the compute layer; it is the state,” Margaret explained, opening the AWS Console. “You can deploy Lambda functions to Oregon (us-west-2) in seconds. But if your user&#39;s cart data is stuck in Virginia (us-east-1), the Oregon compute layer is useless.&quot;</p><p>Margaret opened Timothy’s AWS Cloud Development Kit (CDK) stack to upgrade his database.</p><pre>const { Table, AttributeType, BillingMode } = require(&#39;aws-cdk-lib/aws-dynamodb&#39;);<br><br>// Upgrading the standard table to a Global Table<br>const checkoutTable = new Table(this, &#39;CheckoutTable&#39;, {<br>    partitionKey: { name: &#39;userId&#39;, type: AttributeType.STRING },<br>    billingMode: BillingMode.PAY_PER_REQUEST,<br>    // This single line commands AWS to replicate the data across the continent<br>    replicationRegions: [&#39;us-west-2&#39;],<br>});</pre><p>“By simply adding replicationRegions, you have transformed a standard table into a DynamoDB Global Table,&quot; Margaret said. &quot;Now, every time a customer writes a record to Virginia, AWS natively and asynchronously replicates that exact record to Oregon. The replication latency is typically under one second.&quot;</p><p>“That has to cost extra,” Timothy noted.</p><p>“It does add a premium to our database costs,” Margaret acknowledged, “but it is exponentially cheaper than a sixteen-hour total business outage. When Virginia goes dark, Oregon has an exact, up-to-the-second copy of your entire business. This gives us a <strong>Recovery Point Objective (RPO)</strong> of near zero.”</p><h3>Route 53 for Managing Traffic</h3><p>“Okay, the data is safe in two places,” Timothy nodded, mapping it out in his head. “And I can deploy a backup API Gateway and Lambda stack to Oregon. But in this Active-Passive setup, if the customer’s browser is trying to talk to the Virginia API, how do we physically reroute them when the outage hits?”</p><p>“We use the internet’s traffic cop: <strong>Amazon Route 53</strong>,” Margaret replied.</p><p>“We set up a Route 53 Health Check that constantly pings your primary Virginia API,” she continued. “We configure a DNS Failover Routing Policy. As long as the health check returns a 200 OK, Route 53 sends all your customers to us-east-1. But if that health check fails three times in a row, Route 53 automatically flips the switch at the DNS level. The next time a customer clicks &#39;Checkout,&#39; their browser is instantly routed to your standby API in us-west-2. This gives us a <strong>Recovery Time Objective (RTO)</strong> of just minutes.&quot;</p><p>“And because our DynamoDB Global Table already replicated their cart data to Oregon a second ago…” Timothy realized, his eyes widening.</p><p>“The customer experiences zero data loss,” Margaret finished. “They might see a slight bump in network latency, but the application stays online while your competitors’ websites crash.”</p><p>Timothy updated his architecture diagram, drawing a thick line connecting the East Coast to the West Coast. After seventy distinct architectural upgrades, his system was no longer just resilient; it was continent-spanning.</p><h3>Key Concepts Introduced</h3><p><strong>Region-Wide Outages:</strong> While the cloud is highly reliable, entire geographic regions (like us-east-1 in N. Virginia) can and do experience severe outages due to power failures, fiber cuts, or massive networking events. Single-region architectures are vulnerable to complete downtime during these events.</p><p><strong>DynamoDB Global Tables:</strong> A fully managed, multi-region database. It automatically replicates data across your choice of AWS Regions. It resolves the hardest part of disaster recovery — data synchronization — by ensuring that secondary regions have near-real-time copies of your primary state.</p><p><strong>RPO and RTO:</strong> <strong>Recovery Point Objective (RPO)</strong> is the maximum acceptable amount of data loss measured in time (e.g., near-zero with Global Tables). <strong>Recovery Time Objective (RTO)</strong> is the maximum acceptable amount of downtime before the system is restored (e.g., minutes with Route 53).</p><p><strong>Active-Passive vs. Active-Active:</strong> In an <strong>Active-Passive</strong> setup (demonstrated here), the secondary region’s compute layer sits idle on standby until Route 53 detects a failure and routes traffic to it. In an <strong>Active-Active</strong> setup, both regions serve live customer traffic simultaneously for true zero-downtime performance.</p><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30474a0e2de5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Python: How to Use Threads, Processes, and Asyncio Together]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-python-how-to-use-threads-processes-and-asyncio-together-52cc18305896?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/52cc18305896</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Fri, 01 May 2026 06:16:18 GMT</pubDate>
            <atom:updated>2026-05-01T06:20:56.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHpWh2uANpR1ocAqTLTp5A.jpeg" /></figure><p><em>A practical guide to coordinating CPU-bound math, background logging, and thousands of concurrent users</em></p><p>#PythonConcurrency #AsyncIO #Multiprocessing #Threading</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 42</em></p><p>Timothy stood before his greatest creation: the <strong>Grandmaster Tournament Engine</strong>. It was a massive system designed to handle thousands of live spectators, analyze complex board positions, and log every single move for history.</p><p>“I have a problem, Margaret,” Timothy said, looking at his screen. “I need to do three things at once, and they all have different needs. I need to calculate the math (CPU-bound), I need to talk to 5,000 users (I/O-bound), and I need to save logs to a slow disk without slowing down the game.”</p><p>Margaret smiled and handed him a conductor’s baton. “You aren’t a juggler anymore, Timothy. And you aren’t just a manager or a worker. You are a <strong>Conductor</strong>. You have an orchestra, and it’s time to let them play together.”</p><h3>The Unified Architecture</h3><p>Margaret drew a final diagram on the board. It wasn’t a single room or a single belt — it was a <strong>Symphony Hall</strong>.</p><p>“Every tool has its seat,” she explained. “We use <strong>Asyncio</strong> as the Juggler for the 5,000 users. We use a <strong>Process Pool</strong> as the Muscles for the heavy math. And we use <strong>Threads</strong> as the Helpers for the background logging.”</p><p>Timothy began to write the final code of his journey:</p><pre>import asyncio<br>import time<br>from multiprocessing import Pool<br>from concurrent.futures import ThreadPoolExecutor<br><br># 1. THE MUSCLES: Heavy math lives in a separate Process<br>def heavy_chess_analysis(position):<br>    # Simulating deep calculation<br>    return sum(i * i for i in range(10_000_000))<br># 2. THE HELPER: Logging to disk lives in a Thread<br>def log_move_to_disk(move):<br>    time.sleep(0.1) # Simulating slow disk I/O<br>    print(f&quot;Log: Saved {move} to disk.&quot;)<br>async def main():<br>    # Opening the Talent Agency (Process Pool) and the Helpers (Thread Pool)<br>    with Pool(processes=4) as process_pool:<br>        with ThreadPoolExecutor(max_workers=2) as thread_executor:<br>            loop = asyncio.get_running_loop()<br>            <br>            print(&quot;--- The Symphony Begins ---&quot;)<br>            # 3. THE JUGGLER: Handling the Event Loop<br>            # We use &#39;run_in_executor&#39; to offload work without blocking the loop<br>            <br>            # Offloading math to a Process<br>            analysis_task = loop.run_in_executor(None, heavy_chess_analysis, &quot;Position_A&quot;)<br>            <br>            # Offloading logging to a Thread<br>            log_task = loop.run_in_executor(thread_executor, log_move_to_disk, &quot;e4 to e5&quot;)<br>            # While those work, the Juggler can still handle other users!<br>            print(&quot;Juggler: I&#39;m still free to talk to users while they work!&quot;)<br>            <br>            results = await asyncio.gather(analysis_task, log_task)<br>            print(f&quot;Symphony Result: Analysis {results[0]} complete and move logged.&quot;)<br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(main())</pre><h3>The Masterpiece</h3><p>Timothy watched as his CPU cores lit up with the math, his threads quietly handled the disk in the background, and the Asyncio loop stayed perfectly responsive.</p><p>“It’s beautiful,” Timothy whispered. “They aren’t fighting anymore. They’re… cooperating.”</p><p>“That is the secret of the Specialist,” Margaret said. “There is no ‘best’ tool. There is only the right tool for the right moment. You’ve learned to respect the <strong>Wait</strong>, utilize the <strong>Muscle</strong>, and maintain the <strong>Flow</strong>.”</p><h3>The Specialist’s Final Decree</h3><p>Timothy looked back at everything he had learned — from the very first “Safe Room” to this final “Symphony.” He realized that Python wasn’t just a language for writing scripts; it was a language for orchestrating reality.</p><p>“I’m ready,” Timothy said, closing his laptop.</p><p>“No,” Margaret corrected him with a smile. “You are <strong>finished</strong>. And the next time someone asks you how to make Python do ten things at once, you won’t give them a code snippet. You’ll give them a symphony.”</p><h3>Margaret’s Cheat Sheet</h3><h4>The Right Tool</h4><p><strong>Thousands of Web Requests</strong></p><ul><li>Use <strong>Asyncio</strong> — Efficient on juggling on one core.</li></ul><p><strong>Heavy Math / Image Processing</strong></p><ul><li>Use <strong>Processes</strong> — Break the GIL to use raw CPU power.</li></ul><p><strong>Background Logging / Disk I/O</strong></p><ul><li>Use <strong>Threads</strong> — Low-memory helpers for simple waits.</li></ul><h4>The Final Rules</h4><ul><li><strong>Never Block the Juggler</strong>: If you are in Asyncio, always offload heavy work to a Thread or Process.</li><li><strong>Respect the Memory</strong>: Use Threads for I/O to save RAM; save Processes for when you truly need the Muscle.</li><li><strong>Context Managers are Kings</strong>: Always use with statements to ensure your pools and agencies close properly.</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52cc18305896" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Python: Never Block the Asyncio Loop]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-python-never-block-the-asyncio-loop-4828727e4d36?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/4828727e4d36</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 09:32:52 GMT</pubDate>
            <atom:updated>2026-04-30T09:32:52.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIR_mi09L68VENfPL7rmqw.jpeg" /></figure><p><em>Why CPU-bound code freezes your server and how to fix it with </em><em>to_thread</em></p><p>#PythonAsync #EventLoop #BlockingCode #ResponsiveCode</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 41</em></p><p>Timothy was feeling invincible. He had successfully juggled Alice, Bob, and Charlie using asyncio.gather(). But then, he decided to add one more feature to his ranking request: a <strong>Security Hash</strong>.</p><p>“It’s just a small calculation,” Timothy told Margaret. “Before I return the rank, I’ll run a heavy for loop to generate a secure token. It shouldn&#39;t take more than two seconds. Since it&#39;s inside an async function, the Juggler will just handle it while he waits for the others, right?&quot;</p><p>He added the “Selfish Loop” to Alice’s request.</p><pre>import asyncio<br>import time<br><br>async def check_ranking(player_name, is_selfish=False):<br>    print(f&quot;Juggler: Starting request for {player_name}...&quot;)<br>    <br>    if is_selfish:<br>        # THE TRAP: A heavy CPU task that doesn&#39;t use &#39;await&#39;<br>        print(f&quot;--- {player_name} is being selfish! Starting heavy math... ---&quot;)<br>        # This is a CPU-bound task. It doesn&#39;t throw a ball in the air;<br>        # it forces the Juggler to stand still and calculate.<br>        sum(i * i for i in range(10_000_000)) <br>        print(f&quot;--- {player_name} finished the math. ---&quot;)<br>    <br>    await asyncio.sleep(1) <br>    print(f&quot;Juggler: Finished request for {player_name}!&quot;)<br>async def main():<br>    print(&quot;--- The Juggler is starting the show ---&quot;)<br>    # Alice is going to be the &#39;Selfish&#39; one<br>    await asyncio.gather(<br>        check_ranking(&quot;Alice&quot;, is_selfish=True),<br>        check_ranking(&quot;Bob&quot;),<br>        check_ranking(&quot;Charlie&quot;)<br>    )<br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(main())</pre><p>Timothy hit enter. Usually, Bob and Charlie would start their requests immediately after Alice. But this time, the screen stayed dead.</p><p>Alice started her math. Two seconds passed. <strong>Only after</strong> Alice finished her math did Bob and Charlie’s names even appear on the screen.</p><p>“Margaret!” Timothy cried. “Alice froze the whole stage! Bob and Charlie were just standing there waiting for her to finish her math. Why didn’t the Juggler throw her ball in the air?”</p><h3>The Juggler’s Hands are Full</h3><p>Margaret walked over to the whiteboard. “Remember the Juggler’s hands, Timothy. The Juggler can only throw a ball in the air when they reach an await point.&quot;</p><p>“In your code,” she explained, “Alice started doing heavy math. That’s not ‘waiting’ — that’s ‘working.’ The Juggler had to hold that ball with both hands and focus entirely on the calculation. Because the Juggler was busy, they couldn’t move their hands to pick up Bob or Charlie’s balls.”</p><p>“This is the <strong>Cardinal Sin of Asyncio</strong>,” Margaret said. “If you block the thread with heavy work, the Event Loop stops for everyone. One selfish player just crashed the experience for your other 4,999 users.”</p><h3>The Specialist’s Solution: Offloading</h3><p>“So I can’t do math in Asyncio?” Timothy asked, defeated.</p><p>“You can,” Margaret said, “but you have to send that ball to a different stage. If you have heavy work, you use a <strong>Thread</strong> or a <strong>Process</strong> to do the heavy lifting, and you await the result. In modern Python, we use to_thread to do this easily.&quot;</p><pre># The correct way to offload heavy math so the Juggler stays free<br>def heavy_math():<br>    return sum(i * i for i in range(10_000_000))<br><br># Inside your async function:<br>result = await asyncio.to_thread(heavy_math)</pre><p>“That way,” Margaret said, “the Juggler’s hands stay free to keep the other 4,999 balls moving.”</p><h3>Margaret’s Cheat Sheet: The Rules of the Loop</h3><h4><strong>The Cardinal Rule</strong></h4><ul><li><strong>Never Block the Loop</strong>: Any code that takes a long time to run without an await (like a massive for loop) will freeze the entire program for every user.</li></ul><h4><strong>Detect the Trap</strong></h4><ul><li><strong>Does it do math?</strong> → CPU-bound → Offload it with to_thread.</li><li><strong>Does it wait for a database?</strong> → I/O-bound → Use await.</li><li><strong>Does it use </strong><strong>time.sleep()?</strong> → <strong>STOP.</strong> This is &quot;Selfish.&quot; Always use await asyncio.sleep().</li></ul><h4><strong>The Escape Hatch</strong></h4><ul><li><strong>asyncio.to_thread()</strong>: Added in Python 3.9, this is the easiest way to run a blocking function in a separate thread without freezing the Juggler.</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4828727e4d36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Claude Code: Using AI to Write Documentation]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-claude-code-using-ai-to-write-documentation-dd4859e24b79?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd4859e24b79</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 04:27:44 GMT</pubDate>
            <atom:updated>2026-04-30T04:27:44.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbwNFxEwu9bLcaAX7ef55g.jpeg" /></figure><p><em>How to use Claude Code to keep your docs synchronized with your codebase</em></p><p>#ClaudeCode #CodingWithAI #Documentation #SoftwareEngineering</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 15</em></p><p>Dusk had arrived properly at last, and with it the particular quality of evening light that made the library feel older than it was — the lamps warmer, the shadows deeper, the shelves more permanent. Timothy arrived to find Margaret at her usual table with an unusual companion: a stack of printed pages, heavily annotated, covered in her precise handwriting in three different colors of ink.</p><p>He sat down and looked at the pages without touching them.</p><p>“That looks like a considerable amount of work,” he said.</p><p>“It is the documentation for a system I worked on several years ago,” Margaret said. “I was asked to review it this week. To see whether it still accurately describes what the system does.”</p><p>“And does it?”</p><p>Margaret looked at the pages for a moment. “It describes what the system did when it was written. In the years since, the system has changed considerably. The documentation has not changed at all.” She set her pen down. “It is not wrong, exactly. It is something more insidious than wrong. It is confidently, precisely, beautifully wrong.”</p><p>Timothy understood the particular frustration in her voice. He had encountered documentation like that — detailed, well-written, clearly the product of real effort, and almost entirely misleading because the system it described no longer existed.</p><p>“It lies with authority,” he said.</p><p>“Yes. That is exactly what it does.”</p><h3>Staying Current</h3><p>“How does it happen?” Timothy asked. “The drift. Everyone knows documentation should be kept current. And yet.”</p><p>“And yet,” Margaret agreed. “The reasons are not mysterious. Documentation is written at the moment of maximum understanding — when the system is new, when the decisions are fresh, when the person who built it is still present and can explain it. And then the system changes, and the documentation does not, because changing the documentation feels like overhead. The feature is done. The tests pass. The documentation update is the last item on the list and the first to be deferred.”</p><p>“Until the list is long enough that nobody remembers it exists,” Timothy said.</p><p>“Yes. And by then the documentation has become a liability rather than an asset. It does not just fail to help — it actively misleads. A new developer reads it, trusts it, and builds something on a foundation that no longer exists.” She paused. “The most dangerous documentation is not the missing kind. It is the present, detailed, outdated kind.”</p><p>Timothy thought of the number of times he had spent an hour following documentation only to discover that the system it described had been refactored two years ago. The documentation had cost him more time than having no documentation at all.</p><p>“The absence of documentation is at least honest,” he said.</p><p>“It is,” Margaret said. “Which is a sad thing to have to say about a practice that exists to help people.”</p><h3>What to Contain</h3><p>“Where does Claude Code enter this?” Timothy asked.</p><p>“In several places,” Margaret said. “The first and most immediate is the cost of writing documentation in the first place. Good documentation has always been expensive — it requires time, clarity, and the discipline to explain something you already understand to someone who does not. Claude Code reduces that cost considerably.”</p><p>“You describe the system, it drafts the documentation,” Timothy said.</p><p>“More precisely — you describe what the system does, what decisions were made and why, what constraints exist, what a new developer would need to know to work with it safely. And Claude Code turns that into documentation that is clear, structured, and complete.” She paused. “The thinking is still yours. The articulation is assisted. And the result is documentation that would have taken an hour to write taking fifteen minutes.”</p><p>“Which means the excuse of not having time is harder to sustain,” Timothy said.</p><p>“Yes. But there is something more valuable than speed,” Margaret said. “Claude Code can help you identify what the documentation should contain — which is often the harder problem. Most developers who sit down to write documentation discover that they don’t know where to start. What is obvious to them may not be obvious to the next person. What seems unimportant may be critical. Claude Code, asked the right questions, will tell you what a new developer working with this system would need to know. It will ask you the questions you didn’t think to answer.”</p><h3>Remaining True</h3><p>“There is a second use,” Margaret said, “that I have been thinking about this week more than usual.” She gestured at the annotated pages. “Documentation review. Not writing new documentation — reviewing existing documentation against the current state of the system.”</p><p>“Asking Claude Code whether the documentation is still true,” Timothy said.</p><p>“Yes. You provide the documentation and the current code, and you ask it to identify discrepancies. Where does the documentation describe behavior the code no longer exhibits? Where does the code do things the documentation does not mention?” She paused. “It will not catch everything. But it will catch the obvious drifts — the function signatures that have changed, the parameters that no longer exist, the workflows that have been replaced.”</p><p>“A first pass before the human review,” Timothy said.</p><p>“An efficient first pass. The kind of review that would take a senior developer half a day to do manually, Claude Code can do in minutes. What remains for the human is the judgment — the assessment of whether the discrepancies matter, which ones represent genuine problems, what needs to be updated and what can be retired.” She looked at the annotated pages. “I spent two days on this. With Claude Code, the first pass would have taken an hour. The judgment would still have been mine. But the mechanical comparison — line by line, claim by claim — that is work Claude Code can do.”</p><h3>A Thinking Tool</h3><p>“I want to suggest something,” Timothy said slowly, “that I haven’t fully worked out yet.”</p><p>Margaret waited.</p><p>“We talked about testing as thinking — the idea that writing a test isn’t just verification, it’s a way of understanding the problem more precisely.” He paused. “I think documentation might work the same way. Writing documentation for something you’ve just built forces you to explain it — and in explaining it, you sometimes find that you can’t. That there are parts you don’t fully understand. Decisions you made by instinct that you can’t articulate.”</p><p>“And the inability to articulate them is a signal,” Margaret said.</p><p>“That you don’t understand them as well as you thought,” Timothy said. “Or that the decision was wrong and wouldn’t survive being written down.”</p><p>Margaret looked at him with quiet attention. “This is one of the oldest observations about writing — that the act of writing something down reveals whether you actually understand it. Code can hide incomplete understanding. Tests can hide it. Documentation cannot, because documentation requires you to explain not just what the system does but why.” She paused. “A decision that cannot be documented is a decision that cannot be defended. And a decision that cannot be defended is worth revisiting.”</p><p>Timothy thought of a data model he had designed three weeks ago. He had been confident about it. He had not been able to explain the key architectural choice to his colleague in a way that satisfied either of them. He had moved on anyway.</p><p>“I should have written it down before I moved on,” he said.</p><p>“You should have tried to,” Margaret said. “The trying would have been enough. Either you would have found the words — and understood the decision better — or you would have found that the words weren’t there. And that would have told you something important.”</p><h3>Proof of Understanding</h3><p>“The title of the problem,” Timothy said. “How do you keep it true? Not just write it well initially, but keep it current.”</p><p>“The discipline has two parts,” Margaret said. “The first is proximity — documentation updated at the same time as the code, as part of the same task, not deferred to a separate effort that never happens. Claude Code helps here because it lowers the cost of the update. When you change a function, you ask Claude Code to update the relevant documentation section. It takes minutes rather than the hour that makes it easy to defer.”</p><p>“Making the update the natural conclusion of the task rather than an afterthought,” Timothy said.</p><p>“Yes. The second part is ownership — treating documentation as a living artifact with the same status as code. Not a byproduct of the work. Part of the work.” She looked at him. “A system that works but cannot be explained is only partially complete. The explanation is the other half. And Claude Code, for the first time, makes the other half achievable at a cost that does not make it feel like a punishment.”</p><p>Timothy sat with this for a moment. He had always thought of documentation as the virtuous thing he never quite had time for. He was beginning to understand it differently — not as overhead, but as the evidence that understanding was complete. The test that the thinking had been finished.</p><p>“Documentation isn’t the record of the work,” he said. “It’s the proof that the work was understood.”</p><p>Margaret looked at him steadily. “That is the best definition of it I have heard,” she said. “Yes.”</p><h3>A Clean Page</h3><p>Timothy gathered his things, the library quiet around him, the annotated pages still spread across Margaret’s table like a map of a territory that had moved on without them.</p><p>“Will you update it?” he said. “The documentation.”</p><p>“I will recommend that it be retired and rewritten,” Margaret said. “What is there now is too far from the truth to be salvaged by editing. Sometimes the kindest thing you can do with documentation that has drifted too far is to acknowledge that it is no longer describing anything real — and start again with what is.”</p><p>“A clean page,” Timothy said.</p><p>“With better habits this time,” Margaret said. “That is all documentation ever asks.”</p><p>He walked to the tall doors, the autumn evening outside sharp and clear after the warmth of the library, the first few leaves beginning their long slow letting go.</p><p>Behind him, Margaret uncapped a fresh pen and turned to a clean sheet of paper.</p><p><em>Next episode: Margaret and Timothy turn to the legacy codebase — what it means to work with code you didn’t write, systems you don’t fully understand, and how Claude Code changes the experience of inheriting someone else’s decisions.</em></p><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd4859e24b79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Python: Introduction to Asyncio]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-python-introduction-to-asyncio-a179d5c583e5?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/a179d5c583e5</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 18:36:49 GMT</pubDate>
            <atom:updated>2026-04-28T18:36:49.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iucGH8np6PZmvisiPeFs_w.jpeg" /></figure><p><em>A practical guide to coroutines, the event loop, and cooperative multitasking</em></p><p>#Python #Asyncio #AsyncAwait #ConcurrentProgramming</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 40</em></p><p>Timothy was looking at his Chess Club server. It was popular — so popular that he now had 5,000 players trying to connect at once to check their match rankings.</p><p>“I tried using Threads,” Timothy told Margaret, “but with 5,000 threads, my laptop started screaming. Then I tried Processes, but my memory ran out after just a few dozen. How am I supposed to handle thousands of people at once if I can’t afford the ‘workers’ to watch them?”</p><p>Margaret stood up and picked up three tennis balls. She started to juggle.</p><p>“You’ve been trying to hire 5,000 workers to stand and wait for 5,000 phone calls,” she said, keeping the balls in the air. “That’s expensive. Most of those workers are just sitting there doing nothing while the person on the other end of the line is typing.”</p><p>“You don’t need 5,000 workers,” she said, catching the balls. “You need one <strong>Grand Juggler</strong>.”</p><h3>The Juggler’s Loop</h3><p>“In the world of <strong>Asyncio</strong>,” Margaret explained, “we don’t create new parallel universes. We stay on a single thread, on a single core. But we change how we spend our time.”</p><p>“Think of an <strong>Event Loop</strong>,” she said. “The Juggler (Python) starts a task. The moment that task has to ‘wait’ — like waiting for a database to respond or a player to click a button — the Juggler doesn’t sit and wait with it. They put that ball in the air and immediately grab the next one.”</p><p>Timothy looked at the new syntax. Functions defined with async def are called <strong>coroutines</strong>. They look like Python, but they have a special power: they can be paused and resumed.</p><pre>import asyncio<br><br>async def check_ranking(player_name):<br>    print(f&quot;Juggler: Starting request for {player_name}...&quot;)<br>    <br>    # &#39;await&#39; is the moment the Juggler throws the ball in the air.<br>    # Note: We use asyncio.sleep, NOT time.sleep. <br>    # asyncio.sleep is &#39;cooperative&#39;-it lets the Juggler move to other balls.<br>    # If we used time.sleep(1) here, the Juggler would freeze for EVERYONE!<br>    await asyncio.sleep(1) <br>    <br>    print(f&quot;Juggler: Finished request for {player_name}!&quot;)<br>    return f&quot;{player_name} is Rank #1&quot;<br>async def main():<br>    players = [&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;]<br>    print(&quot;--- The Grand Juggler is starting ---&quot;)<br>    <br>    # &#39;gather&#39; tells the Juggler to keep all these balls in the air at once<br>    results = await asyncio.gather(<br>        check_ranking(&quot;Alice&quot;),<br>        check_ranking(&quot;Bob&quot;),<br>        check_ranking(&quot;Charlie&quot;)<br>    )<br>    print(results)<br># The one line that starts the Event Loop (Requires Python 3.7+)<br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(main())</pre><h3>The Power of the Pause</h3><p>Timothy watched the output. All three “Starting” messages appeared instantly, then a one-second pause, and then all three “Finished” messages appeared together.</p><p>“It took one second total,” Timothy noted. “If this were normal code, it would have taken three seconds. But there’s only one thread! How did it do three things at once?”</p><p>“It didn’t do them at once,” Margaret corrected. “It <strong>waited</strong> for them at once. The Juggler is so fast at switching between balls that it feels like they are all moving. This is how a single Python server can handle thousands of players — by never, ever sitting still.”</p><h3>The Specialist’s Warning: The Juggler’s Weakness</h3><p>“So this is the ultimate tool?” Timothy asked. “Can I use it for my Grandmaster Analysis math, too?”</p><p>Margaret shook her head. “No. Remember the Juggler’s hands. If a task is ‘heavy’ — like a complex math problem — the Juggler has to hold onto that ball and can’t throw it in the air. While they are doing math, the whole Loop stops. Every other player’s ranking would freeze.”</p><p>Timothy realized the distinction. <strong>Threads</strong> are for small waits. <strong>Processes</strong> are for big muscles. <strong>Asyncio</strong> is for the Grand Juggler who needs to handle the whole world at once.</p><h3>Margaret’s Cheat Sheet: Intro to Asyncio</h3><h4>The Concurrency Toolbox</h4><p><strong>Threads</strong><br>Best for: Small I/O waits<br>The Cost: Memory per thread</p><p><strong>Processes</strong><br>Best for: Heavy CPU Math<br>The Cost: High memory &amp; CPU usage</p><p><strong>Asyncio</strong><br>Best for: Thousands of I/O waits<br>The Cost: Single-Threaded discipline</p><h4>The Vocabulary</h4><ul><li><strong>Coroutine</strong>: A function defined with async def. It can be paused and resumed.</li><li><strong>await</strong>: The &quot;Yield&quot; point. It tells Python: &quot;I’m waiting on the outside world; go do something else while I wait.&quot;</li><li><strong>asyncio.run()</strong>: The standard way to start your event loop (requires Python 3.7+).</li></ul><h4>The Specialist’s Wisdom</h4><ul><li><strong>Cooperative Multitasking</strong>: Asyncio relies on you being a good citizen. You must use await to give the Juggler a chance to move to the next task.</li><li><strong>Don’t Block the Juggler</strong>: Never use time.sleep() inside an async function. time.sleep is a &quot;selfish&quot; sleep—it stops the whole thread, which means the Juggler stops juggling for everyone. Always use await asyncio.sleep().</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a179d5c583e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Python: How to Share Data Between Processes]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-python-how-to-share-data-between-processes-3c2b8b6fe75e?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c2b8b6fe75e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 18:36:04 GMT</pubDate>
            <atom:updated>2026-04-28T18:36:04.372Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fHbQLVpcWxqmXbh851W1Q.jpeg" /></figure><p><em>A practical guide to </em><em>Value, </em><em>Array, and when to use queues instead</em></p><p>#Python #Multiprocessing #SharedMemory #ParallelProgramming</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 39</em></p><p>Timothy was looking at his “Grandmaster Analysis” engine. It was fast — blindingly fast — but it had a major flaw. Each of his four worker processes was living in its own <strong>Parallel Universe</strong>.</p><p>“Margaret,” Timothy said, “I want to display a live ‘Global High Score’ on my screen. I want every worker to be able to add to the same total whenever they find a winning move. But when I use a normal global variable, each worker just updates their own private copy. At the end, my main program still thinks the total is zero!”</p><p>Margaret nodded. “That’s the cost of Multiprocessing, Timothy. Since each process has its own memory, they can’t see each other’s notes. To them, the other workers don’t even exist.”</p><p>“But,” she added, eyes twinkling, “we can build a <strong>Wormhole</strong>.”</p><h3>The Value and the Array</h3><p>“Python gives us a special way to carve out a tiny piece of memory that sits <em>outside</em> the parallel universes,” Margaret explained. “We call it <strong>Shared Memory</strong>. In the multiprocessing module, we use a Value for a single piece of data, or an Array for a fixed-size list.&quot;</p><p>Timothy looked at the code. It looked familiar, but with a twist.</p><pre>from multiprocessing import Process, Value, Lock<br>import time<br><br>def record_win(shared_total, lock):<br>    for _ in range(100):<br>        time.sleep(0.01)<br>        # We still need a Lock, even in parallel universes!<br>        with lock:<br>            shared_total.value += 1<br>if __name__ == &quot;__main__&quot;:<br>    # &#39;i&#39; stands for integer (Type Code), and we start at 0<br>    # This &#39;Value&#39; lives in a shared space all processes can see<br>    global_wins = Value(&#39;i&#39;, 0)<br>    win_lock = Lock()<br>    processes = [Process(target=record_win, args=(global_wins, win_lock)) for _ in range(4)]<br>    for p in processes: p.start()<br>    for p in processes: p.join()<br>    print(f&quot;Final Global Wins: {global_wins.value}&quot;)</pre><h3>The Price of the Wormhole</h3><p>Timothy watched the number climb perfectly to 400. “It works! They’re all touching the same scoreboard!”</p><p>“They are,” Margaret cautioned. “But look closely at the code. Did you notice the Lock?&quot;</p><p>“I thought we didn’t need Locks in Multiprocessing because of the separate GILs?” Timothy asked.</p><p>“The GIL only protects Python’s internal soul,” Margaret said. “It doesn’t protect <strong>Shared Memory</strong>. The second you build a bridge between universes, you bring back the <strong>Race Condition</strong>. If two workers try to update the Value at the exact same millisecond, they will still overwrite each other.&quot;</p><h3>The Specialist’s Warning</h3><p>Timothy realized the gravity of what he had built. “So, by sharing memory, I’ve brought back all the dangers of Threading (Locks, Deadlocks, Race Conditions) but with the high memory cost of Multiprocessing?”</p><p>“Exactly,” Margaret said. “Shared Memory is the most powerful — and most dangerous — tool in the kit. Most of the time, you should stay on the <strong>Conveyor Belt</strong> (Queues) because it’s safer. But when you absolutely need a ‘Global Scoreboard,’ now you know how to build the wormhole.”</p><h3>Margaret’s Cheat Sheet: Shared Memory</h3><p><strong>The Decision Guide</strong></p><ul><li><strong>Share a simple counter …Use</strong>Value + Lock</li><li><strong>Share a fixed-size list...Use </strong>Array + Lock</li><li><strong>Share a complex dict/list...Use </strong>Manager (Slower, but flexible)</li><li><strong>Send work/messages…Use </strong>Queue (Safe &amp; Preferred)</li></ul><p><strong>The Specialist’s Wisdom</strong></p><ul><li><strong>Type Codes</strong>: When using Value or Array, you must specify the type: &#39;i&#39; for integer, &#39;f&#39; for float, or &#39;d&#39; for double.</li><li><strong>The </strong><strong>.value Attribute</strong>: Unlike normal variables, you must read or write to the .value property of a Value object.</li><li><strong>The “Shared Memory” Tax</strong>: Accessing shared memory is significantly slower than accessing local memory. Use it sparingly for “High Scores,” not for your main data processing.</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c2b8b6fe75e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of Python: Using imap for Streaming Results]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-python-using-imap-for-streaming-results-838b62732036?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/838b62732036</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 09:55:07 GMT</pubDate>
            <atom:updated>2026-04-27T09:55:07.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cKi6Qq6OX-gdShZTQEL_Q.jpeg" /></figure><p><em>How to process data as it finishes, not when everything is done</em></p><p>#Python #Multiprocessing #StreamingResults #imap</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — the kind of place where code quality is the unspoken objective, and craftsmanship is the only thing that matters.</em></p><p><em>Episode 38</em></p><p>Timothy was happy with his new <strong>Process Pool</strong> — a tool that let him hire a “fleet” of workers to analyze chess matches across all the cores of his CPU. But he noticed a frustrating bottleneck.</p><p>Some of his chess matches were “Blitz” games (taking seconds to analyze), while others were “Marathons” (taking minutes).</p><p>“Margaret,” Timothy said, “the standard pool.map command is making me wait. If the first match in the pile is a slow Marathon, I don&#39;t see the results of the nine fast Blitz matches until that one slow one finishes. I’m sitting here with an empty screen when I could be working on the results that are already done!&quot;</p><p>Margaret nodded. “You’re dealing with <strong>Blocking</strong>. The standard map command is a perfectionist; it waits until every single worker has finished the entire stack of work before it hands you the final list. If you want to be an <strong>Impatient Manager</strong>, you need a <strong>stream</strong>, not a pile.&quot;</p><h3>The Streaming Concept</h3><p>“Think of it like a <strong>Conveyor Belt</strong>,” Margaret explained. “In the standard ‘perfectionist’ way, the belt doesn’t move until the very last box is packed. But if you use pool.imap, the belt starts moving the second the first worker is done. You can pick up the fast results as they arrive, even while the slow worker is still sweating over their desk.&quot;</p><h3>Seeing the Results in Real-Time</h3><p>Timothy updated his code. He traded the static “pile” of results for a dynamic loop that watched the belt.</p><pre>from multiprocessing import Pool<br>import time<br>import random<br><br>def analyze_match(match_id):<br>    # Some matches are fast (0.5s), some are slow (3s)<br>    duration = random.uniform(0.5, 3.0)<br>    time.sleep(duration) <br>    return f&quot;Match #{match_id} analyzed in {duration:.1f}s&quot;<br>if __name__ == &quot;__main__&quot;:<br>    match_ids = range(1, 11) # A stack of 10 matches<br>    <br>    # We open a Pool with 4 workers<br>    with Pool(processes=4) as pool:<br>        print(&quot;--- The Impatient Manager is watching the belt ---&quot;)<br>        <br>        # &#39;imap&#39; returns an iterator-a live stream of results<br>        result_stream = pool.imap(analyze_match, match_ids)<br>        for result in result_stream:<br>            # This prints the MOMENT each task is ready<br>            print(f&quot;Manager received: {result}&quot;)</pre><p>Timothy watched the screen. Instead of a long, silent pause followed by ten lines appearing at once, the results started “popping” onto the screen one by one.</p><p>“I’m still getting them in the order I sent them,” Timothy noted, “but I’m not waiting for the <em>entire</em> list to be ready. It feels much more alive.”</p><h3>The Specialist’s Agility: Lazy Evaluation</h3><p>“That’s the power of <strong>Lazy Evaluation</strong>,” Margaret said. “You aren’t loading the results into a massive, heavy pile in memory. You’re letting them flow through your program. If you had a million matches, the ‘perfectionist’ map might crash your computer by trying to build a giant million-item list before showing you anything. imap just keeps the stream moving.&quot;</p><p>Timothy looked at the steady drip of results. He had moved from being a manager who waits for a final report to a manager who watches the live dashboard.</p><h3>Margaret’s Cheat Sheet: The Streaming Pool</h3><p><strong>Choosing Your Strategy</strong></p><p>map()<br><strong>Blocking</strong><br><strong>When to use</strong>: Small batches where you need a complete list at once.</p><p>imap()<br><strong>Streaming</strong><br><strong>When to use</strong>: Large data where you want to see results as they finish.</p><p>imap_unordered()<br><strong>Fastest</strong><br><strong>When to use</strong>: When you want results the instant they are done, regardless of order.</p><p><strong>The Specialist’s Wisdom</strong></p><ul><li><strong>Lazy Evaluation</strong>: imap is &quot;lazy&quot; (in a good way). It only processes and yields results as you ask for them, making it incredibly memory-efficient for Big Data.</li><li><strong>Order Preservation</strong>: Standard imap still respects your input order. If Item #1 is slow, the stream will wait for it before showing Items #2 and #3.</li><li><strong>The Chunksize Tip</strong>: For millions of tiny tasks, use pool.imap(func, data, chunksize=100). This sends work to your CPU in &quot;batches&quot; instead of one by one, which is much more efficient.</li></ul><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=838b62732036" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Secret Life of AI: Why Your Best Prompts Fail]]></title>
            <link>https://medium.com/@aaron.rose.tx/the-secret-life-of-ai-why-your-best-prompts-fail-37c0a8c41c1c?source=rss-392ce918ae14------2</link>
            <guid isPermaLink="false">https://medium.com/p/37c0a8c41c1c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[writing-prompts]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Aaron Rose]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 08:53:42 GMT</pubDate>
            <atom:updated>2026-04-27T08:53:42.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8IJusyoe5f4J9wNRDhAjw.jpeg" /></figure><p><em>How to prompt, think, and get results from any AI tool</em></p><p>#WorkingWithAI #Prompting #AIConfidence</p><p><em>Margaret is a senior software engineer. Timothy is her junior colleague. They work in a grand Victorian library in London — and in every episode, they’ll show you exactly how to get what you want from AI.</em></p><p><em>Episode 6</em></p><p>Timothy set his notebook on the table with the quiet precision of someone who had prepared carefully and was still confused about what had gone wrong.</p><p>“I did everything right,” he said.</p><p>Margaret looked up. She recognized that particular frustration — not the hot anger of the rage quit, but the cooler, more bewildering feeling of having followed the instructions and still arrived nowhere useful.</p><p>“Tell me,” she said.</p><p>“I spent twenty minutes on the prompt.” He opened the notebook. “Specific. Clear. Structured. The kind of prompt you’d hold up as an example.” He paused. “The output was useless. Generic. Like it hadn’t heard a word I said.”</p><p>Margaret nodded slowly. “What were you asking it to help you with?”</p><p>“A proposal. For a client I’ve been working with for two years.”</p><p>She was quiet for a moment. Then: “And how much of those two years did you put in the prompt?”</p><p>Timothy looked at her. “What do you mean?”</p><p>“The client,” she said. “Their industry. Their particular concerns. The history between you. The tone they respond to. The thing they almost said no to last time.” She folded her hands. “How much of that was in your prompt?”</p><p>He said nothing.</p><p>“That,” Margaret said, “is context.”</p><h3>The AI Doesn’t Know What You Know</h3><p>She stood and walked to the shelves, running a finger along a row of spines without pulling anything out. It was a habit Timothy had come to recognize — she thought better when she was moving.</p><p>“Here is the thing most people never quite grasp,” she said. “You walk into a conversation with an AI carrying everything you know. Two years of client history. Industry nuance. Unspoken preferences. Lessons from previous failures. All of it present in your mind, shaping every word you type.”</p><p>She turned to face him.</p><p>“The AI walks in with none of it.”</p><p>Timothy leaned back. “So the prompt wasn’t the problem.”</p><p>“The prompt was fine. The briefing was missing.” She returned to her chair. “There is a difference between asking a good question and giving someone enough to actually answer it well. You asked a good question. You assumed the answer lived somewhere in the question itself. It didn’t.”</p><p>“Because the AI doesn’t know what I know.”</p><p>“It knows what you tell it,” Margaret said. “Nothing more. Nothing less. Every assumption you carry silently into the conversation — every piece of background you consider obvious — is invisible to the tool. It cannot read the two years. It can only read the prompt.”</p><p>Timothy was quiet for a moment, turning this over.</p><p>“So the prompt is only half the job.”</p><p>“The smaller half,” Margaret said. “On a good day.”</p><h3>Give the AI Enough to Work With</h3><p>She picked up her pen and wrote two lines on a piece of paper, then handed it to Timothy. He read it slowly.</p><ol><li><em>What do you want?</em></li><li><em>What does the AI need to know to give it to you?</em></li></ol><p>“Most people answer the first and skip the second entirely,” she said. “They treat the AI like a search engine — type the query, receive the answer. But a search engine retrieves. The AI reasons. And reasoning requires material to work with.”</p><p>Timothy studied the two lines. “So before I write the prompt I should be writing the context.”</p><p>“Before you write the prompt you should be asking yourself: what does this tool not know that it needs to know?” She tapped the paper. “The client’s industry. The audience for the proposal. The tone that has worked before. The constraints you’re working within. The thing you’re trying to avoid. Give it the briefing, not just the question.”</p><p>Timothy nodded slowly. “So instead of ‘write a proposal for a cloud migration’ it’s ‘write a proposal for a client who is terrified of downtime, loves bullet points, and rejected our last bid because it felt too corporate.’”</p><p>“Now you’re giving it something to chew on,” Margaret said.</p><p>“And if I had done that — “</p><p>“You would have gotten something useful,” Margaret said simply. “Not because the prompt was better. Because the AI finally had enough to work with.”</p><h3>Giving the AI a Proper Briefing</h3><p>Timothy turned to a fresh page in his notebook.</p><p>“How much context is enough?”</p><p>Margaret considered this. “Enough that a capable stranger — someone intelligent, willing to help, but knowing nothing about your situation — could do something useful with it.” She paused. “That is essentially what you are working with every time. A capable stranger. Treat it accordingly.”</p><p>“So if I wouldn’t expect a new colleague to produce something brilliant on their first day without a proper briefing — “</p><p>“Then you should not expect the AI to do it either.” She smiled. “The tool is not failing you when it gives you something generic in response to a context-free prompt. It is doing exactly what it can with what it has. Which is very little, if you gave it very little.”</p><p>Timothy wrote that down. Then looked up.</p><p>“The frustrating part is that it sounds so confident even when it has nothing to work with.”</p><p>“Yes,” Margaret said. “That is a separate problem for a future conversation.” She picked up her book again. “For now — next time you sit down with the tool, try writing the context before you write the prompt. Everything the AI doesn’t know but needs to. Then the prompt.”</p><p>“And if it still goes wrong?”</p><p>She looked at him over the top of her book.</p><p>“Then at least you’ll know it wasn’t the context.”</p><p><em>The Secret Life of AI is a series about the human side of working with artificial intelligence — the skills, habits, and mindset that determine whether the tool works for you or against you. Because the missing piece was never the AI.</em></p><p><em>Next episode: The AI sounds certain. That doesn’t mean it’s right.</em></p><p><em>Aaron Rose is a software engineer and technology writer at </em><a href="https://www.tech-reader.blog/"><em>tech-reader.blog</em></a><em>. For explainer videos and podcasts, check out </em><a href="https://www.youtube.com/@tech-reader2007"><em>Tech-Reader YouTube channel</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37c0a8c41c1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>