1:"$Sreact.fragment"
2:I[15579,["/_next/static/chunks/fd0661f1506dcbc6.js","/_next/static/chunks/94245cbda44972fe.js","/_next/static/chunks/af778fff4a0f4be6.js","/_next/static/chunks/b096b037d08e2f31.js"],"Navigation"]
3:I[3013,["/_next/static/chunks/fd0661f1506dcbc6.js","/_next/static/chunks/94245cbda44972fe.js","/_next/static/chunks/af778fff4a0f4be6.js","/_next/static/chunks/b096b037d08e2f31.js"],""]
5f:I[41451,["/_next/static/chunks/fd0661f1506dcbc6.js","/_next/static/chunks/94245cbda44972fe.js","/_next/static/chunks/af778fff4a0f4be6.js","/_next/static/chunks/b096b037d08e2f31.js"],"Footer"]
60:I[47913,["/_next/static/chunks/316a3a63422f35de.js"],"OutletBoundary"]
61:"$Sreact.suspense"
:HL["/blog/posts/stream-wrapper-pattern/hero.jpg","image"]
:HL["/blog/posts/logo.png","image"]
0:{"buildId":"TlpKRvbES4zzM7LeczAM7","rsc":["$","$1","c",{"children":[[["$","$L2",null,{}],["$","main",null,{"className":"pt-20 md:pt-24","children":["$","article",null,{"children":[["$","header",null,{"className":"border-b border-border","children":["$","div",null,{"className":"container mx-auto px-6 py-14 md:py-20","children":[["$","$L3",null,{"href":"/blog","className":"mb-8 inline-flex items-center text-sm font-medium text-muted-foreground transition-colors hover:text-foreground","children":[["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-arrow-left mr-2 h-4 w-4","aria-hidden":"true","children":[["$","path","1l729n",{"d":"m12 19-7-7 7-7"}],["$","path","x3x0zl",{"d":"M19 12H5"}],"$undefined"]}],"Blog"]}],["$","div",null,{"className":"grid gap-8 md:grid-cols-[1fr_0.9fr] md:items-start","children":[["$","div",null,{"className":"max-w-3xl","children":[["$","div",null,{"className":"mb-5 flex flex-wrap items-center gap-3 text-sm text-muted-foreground","children":[["$","span",null,{"className":"rounded-md border border-primary/40 bg-primary/10 px-2.5 py-1 text-primary","children":"Backend"}],["$","span",null,{"children":"2026-W18"}],["$","span",null,{"aria-hidden":"true","children":"/"}],["$","span",null,{"children":"3 min read"}],null]}],["$","h1",null,{"className":"text-4xl font-bold leading-tight text-balance md:text-6xl","children":"The Stream Wrapper Pattern for Transparent Event Capture"}],["$","p",null,{"className":"mt-6 text-lg leading-relaxed text-muted-foreground md:text-xl","children":"When wrapping an SDK to add observability, usage data lives in the final chunk of a stream. The `finally` block in `__iter__` is the one place you're guaranteed to see it."}]]}],["$","div",null,{"className":"overflow-hidden rounded-lg border border-border bg-card","children":["$","div",null,{"className":"relative aspect-[16/9] overflow-hidden","children":[null,["$","img",null,{"src":"/blog/posts/stream-wrapper-pattern/hero.jpg","alt":"A clear glass laboratory pipette suspended over a beaker with a single amber drop forming at its tip.","className":"h-full w-full object-cover"}],["$","img",null,{"src":"/blog/posts/logo.png","alt":"","aria-hidden":"true","className":"pointer-events-none absolute right-4 top-4 h-[50px] w-[50px] mix-blend-screen"}]]}]}]]}]]}]}],["$","div",null,{"className":"container mx-auto px-6 py-12 md:py-16","children":["$","div",null,{"className":"grid gap-10 lg:grid-cols-[minmax(0,1fr)_280px] lg:items-start","children":[["$","div",null,{"className":"max-w-3xl text-muted-foreground","children":[[["$","h2","h2-0",{"className":"mt-12 text-2xl font-semibold leading-snug text-foreground first:mt-0","children":"The problem"}],"\n",["$","p","p-0",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":["When you wrap an SDK client to add observability, streaming responses break the standard approach. With a non-streaming call you get a single response object back and can read ",["$","code","code-0",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":".usage"}]," off it immediately. With streaming, the usage data lives inside the final chunk of the iterator — it isn't available until the caller has consumed the whole stream. If your wrapper reads usage in the ",["$","code","code-1",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"finally"}]," block before the caller iterates, you get ",["$","code","code-2",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"None"}]," for every token count."]}],"\n",["$","h2","h2-1",{"className":"mt-12 text-2xl font-semibold leading-snug text-foreground first:mt-0","children":"The approach"}],"\n","$L4","\n","$L5","\n","$L6","\n","$L7","\n","$L8","\n","$L9","\n","$La"],"$Lb",null]}],"$Lc"]}]}]]}]}],"$Ld"],["$Le","$Lf","$L10"],"$L11"]}],"loading":null,"isPartial":false}
4:["$","p","p-1",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":"The stream wrapper is a thin proxy class with a single responsibility: intercept iteration and emit an accounting event when the stream exhausts."}]
5:["$","div","pre-0",{"style":{"background":"hsl(220, 13%, 18%)","color":"hsl(220, 14%, 71%)","textShadow":"0 1px rgba(0, 0, 0, 0.3)","fontFamily":"\"Fira Code\", \"Fira Mono\", Menlo, Consolas, \"DejaVu Sans Mono\", monospace","direction":"ltr","textAlign":"left","whiteSpace":"pre","wordSpacing":"normal","wordBreak":"normal","lineHeight":"1.5","MozTabSize":"2","OTabSize":"2","tabSize":"2","WebkitHyphens":"none","MozHyphens":"none","msHyphens":"none","hyphens":"none","padding":"1rem","margin":"0.5em 0","overflow":"auto","borderRadius":"0.5rem","marginTop":"1.25rem","marginBottom":0,"border":"1px solid hsl(var(--border))","fontSize":"0.875rem"},"children":["$","code",null,{"style":{"whiteSpace":"pre","fontFamily":"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace"},"children":[false,[["$","span","code-segment-0",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["class"]}],["$","span","code-segment-1",{"style":{},"children":[" "]}],["$","span","code-segment-2",{"className":"token","style":{"color":"hsl(29, 54%, 61%)"},"children":["_StreamWrapper"]}],["$","span","code-segment-3",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}],["$","span","code-segment-4",{"style":{},"children":["\n"]}],["$","span","code-segment-5",{"style":{},"children":["    "]}],["$","span","code-segment-6",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["def"]}],["$","span","code-segment-7",{"style":{},"children":[" "]}],["$","span","code-segment-8",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["__init__"]}],["$","span","code-segment-9",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}],["$","span","code-segment-10",{"style":{},"children":["self"]}],["$","span","code-segment-11",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}],["$","span","code-segment-12",{"style":{},"children":[" stream"]}],["$","span","code-segment-13",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}],["$","span","code-segment-14",{"style":{},"children":[" "]}],["$","span","code-segment-15",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["*"]}],["$","span","code-segment-16",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}],["$","span","code-segment-17",{"style":{},"children":[" session_id"]}],["$","span","code-segment-18",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}],["$","span","code-segment-19",{"style":{},"children":[" model"]}],["$","span","code-segment-20",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}],["$","span","code-segment-21",{"style":{},"children":[" t0"]}],["$","span","code-segment-22",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}],["$","span","code-segment-23",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}],["$","span","code-segment-24",{"style":{},"children":["\n"]}],["$","span","code-segment-25",{"style":{},"children":["        self"]}],["$","span","code-segment-26",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}],["$","span","code-segment-27",{"style":{},"children":["_stream "]}],["$","span","code-segment-28",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["="]}],["$","span","code-segment-29",{"style":{},"children":[" stream\n"]}],["$","span","code-segment-30",{"style":{},"children":["        self"]}],["$","span","code-segment-31",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}],["$","span","code-segment-32",{"style":{},"children":["_input_tokens "]}],["$","span","code-segment-33",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["="]}],["$","span","code-segment-34",{"style":{},"children":[" "]}],["$","span","code-segment-35",{"className":"token","style":{"color":"hsl(29, 54%, 61%)"},"children":["None"]}],["$","span","code-segment-36",{"style":{},"children":["\n"]}],["$","span","code-segment-37",{"style":{},"children":["        self"]}],["$","span","code-segment-38",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}],["$","span","code-segment-39",{"style":{},"children":["_output_tokens "]}],["$","span","code-segment-40",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["="]}],["$","span","code-segment-41",{"style":{},"children":[" "]}],["$","span","code-segment-42",{"className":"token","style":{"color":"hsl(29, 54%, 61%)"},"children":["None"]}],"$L12","$L13","$L14","$L15","\n","$L16","$L17","$L18","$L19","$L1a","$L1b","$L1c","$L1d","$L1e","$L1f","$L20","$L21","$L22","$L23","$L24","$L25","$L26","$L27","$L28","$L29","$L2a","$L2b","$L2c","$L2d","$L2e","$L2f","$L30","$L31","$L32","$L33","$L34","$L35","$L36","$L37","$L38","$L39","$L3a","$L3b","$L3c","$L3d","$L3e","$L3f","$L40","$L41","$L42","$L43","$L44","$L45","\n","$L46","$L47","$L48","$L49","$L4a","$L4b","$L4c","$L4d","$L4e","$L4f","$L50","$L51","$L52","$L53","$L54","$L55","$L56","$L57","$L58","$L59","$L5a","$L5b","$L5c","$L5d"]]}]}]
6:["$","p","p-2",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":[["$","code","code-0",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"_capture"}]," inspects each chunk for usage data — for Anthropic this means watching for ",["$","code","code-1",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"RawMessageStartEvent"}]," (input tokens) and ",["$","code","code-2",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"RawMessageDeltaEvent"}]," (output tokens). For OpenAI with ",["$","code","code-3",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"stream_options={\"include_usage\": True}"}],", usage lands on the last chunk."]}]
7:["$","p","p-3",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":[["$","code","code-0",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"_emit_final"}]," runs in the ",["$","code","code-1",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"finally"}]," block so it fires whether the caller consumes the whole stream, breaks early, or raises. It has all the counts by then and emits a ",["$","code","code-2",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"stream_end"}]," event with real numbers."]}]
8:["$","p","p-4",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":["The caller's code is unchanged — they still ",["$","code","code-0",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"for chunk in resp:"}]," exactly as before. ",["$","code","code-1",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"isinstance(resp._stream, OriginalType)"}]," still holds for any code that inspects the type."]}]
9:["$","h2","h2-2",{"className":"mt-12 text-2xl font-semibold leading-snug text-foreground first:mt-0","children":"What I learned"}]
a:["$","p","p-5",{"className":"mt-4 text-base leading-8 md:text-lg first:mt-0 first:text-xl first:leading-relaxed first:text-foreground md:first:text-2xl","children":["The ",["$","code","code-0",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"finally"}]," in ",["$","code","code-1",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"__iter__"}]," is the key insight. A ",["$","code","code-2",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"try/finally"}]," wrapping a generator's yield loop runs the ",["$","code","code-3",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"finally"}]," when the generator is garbage-collected or when a ",["$","code","code-4",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"return"}],"/",["$","code","code-5",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"StopIteration"}]," is raised — which covers every exit path. You get one guaranteed emission point regardless of how the caller drives the iterator. The alternative — hooking ",["$","code","code-6",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"__del__"}]," — is unreliable under CPython and completely unreliable under PyPy. The iterator protocol's ",["$","code","code-7",{"className":"rounded bg-secondary px-1.5 py-0.5 text-[0.9em] text-foreground","children":"finally"}]," is the right tool."]}]
b:["$","div",null,{"className":"mt-14 border-t border-border pt-8","children":["$","$L3",null,{"href":"/platform","className":"inline-flex items-center text-sm font-medium text-primary transition-colors hover:text-primary/80","children":["Start a build",["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-arrow-right ml-2 h-4 w-4","aria-hidden":"true","children":[["$","path","1ays0h",{"d":"M5 12h14"}],["$","path","xquz4c",{"d":"m12 5 7 7-7 7"}],"$undefined"]}]]}]}]
c:["$","aside",null,{"className":"hidden lg:block","children":["$","div",null,{"className":"sticky top-24 space-y-4","children":[["$","h3",null,{"className":"text-xs font-semibold uppercase tracking-wider text-primary","children":["More in ","Backend"]}],["$","div",null,{"className":"space-y-4","children":[["$","$L3","idempotency-scheduled-jobs",{"href":"/blog/idempotency-scheduled-jobs","className":"block overflow-hidden rounded-lg border border-border bg-card transition-colors hover:border-primary/40","children":[["$","div",null,{"className":"relative aspect-[16/9] overflow-hidden bg-secondary/70","children":[["$","img",null,{"src":"/blog/posts/idempotency-scheduled-jobs/hero.jpg","alt":"An industrial timestamp clock on a worn wooden desk with two identical printed slips showing the same stamped time stacked beside it, soft window light, no people.","className":"h-full w-full object-cover","loading":"lazy","decoding":"async"}],["$","img",null,{"src":"/blog/posts/logo.png","alt":"","aria-hidden":"true","className":"pointer-events-none absolute right-2 top-2 h-[24px] w-[24px] mix-blend-screen"}]]}],["$","div",null,{"className":"p-4","children":[["$","p",null,{"className":"text-xs font-medium text-primary","children":"Backend"}],["$","p",null,{"className":"mt-1 text-xs text-muted-foreground","children":["2026-W20"," · ","4 min"]}],["$","p",null,{"className":"mt-2 line-clamp-2 text-sm font-semibold leading-snug text-foreground","children":"Idempotency in Scheduled Jobs — The Restart Problem"}]]}]]}],["$","$L3","pydantic-production-fail-fast",{"href":"/blog/pydantic-production-fail-fast","className":"block overflow-hidden rounded-lg border border-border bg-card transition-colors hover:border-primary/40","children":[["$","div",null,{"className":"relative aspect-[16/9] overflow-hidden bg-secondary/70","children":[["$","img",null,{"src":"/blog/posts/pydantic-production-fail-fast/hero.jpg","alt":"A solid brass padlock with its key still inserted, resting on a worn leather-bound logbook with handwritten entries, soft warm desk light, no people, editorial.","className":"h-full w-full object-cover","loading":"lazy","decoding":"async"}],["$","img",null,{"src":"/blog/posts/logo.png","alt":"","aria-hidden":"true","className":"pointer-events-none absolute right-2 top-2 h-[24px] w-[24px] mix-blend-screen"}]]}],["$","div",null,{"className":"p-4","children":[["$","p",null,{"className":"text-xs font-medium text-primary","children":"Backend"}],["$","p",null,{"className":"mt-1 text-xs text-muted-foreground","children":["2026-W20"," · ","5 min"]}],["$","p",null,{"className":"mt-2 line-clamp-2 text-sm font-semibold leading-snug text-foreground","children":"Fail Fast at the Right Boundary — Pydantic Settings in Production"}]]}]]}],["$","$L3","postgres-notify-ws-delivery",{"href":"/blog/postgres-notify-ws-delivery","className":"block overflow-hidden rounded-lg border border-border bg-card transition-colors hover:border-primary/40","children":[["$","div",null,{"className":"relative aspect-[16/9] overflow-hidden bg-secondary/70","children":[["$","img",null,{"src":"/blog/posts/postgres-notify-ws-delivery/hero.jpg","alt":"Close shot of a server rack with a single blinking amber LED in an otherwise dark row.","className":"h-full w-full object-cover","loading":"lazy","decoding":"async"}],["$","img",null,{"src":"/blog/posts/logo.png","alt":"","aria-hidden":"true","className":"pointer-events-none absolute right-2 top-2 h-[24px] w-[24px] mix-blend-screen"}]]}],["$","div",null,{"className":"p-4","children":[["$","p",null,{"className":"text-xs font-medium text-primary","children":"Backend"}],["$","p",null,{"className":"mt-1 text-xs text-muted-foreground","children":["2026-W18"," · ","3 min"]}],["$","p",null,{"className":"mt-2 line-clamp-2 text-sm font-semibold leading-snug text-foreground","children":"Postgres NOTIFY as a WebSocket Delivery Mechanism"}]]}]]}]]}],["$","$L3",null,{"href":"/blog?category=backend","className":"inline-flex items-center text-sm font-medium text-primary transition-colors hover:text-primary/80","children":["Read all in ","Backend","$L5e"]}]]}]}]
d:["$","$L5f",null,{}]
e:["$","script","script-0",{"src":"/_next/static/chunks/94245cbda44972fe.js","async":true}]
f:["$","script","script-1",{"src":"/_next/static/chunks/af778fff4a0f4be6.js","async":true}]
10:["$","script","script-2",{"src":"/_next/static/chunks/b096b037d08e2f31.js","async":true}]
11:["$","$L60",null,{"children":["$","$61",null,{"name":"Next.MetadataOutlet","children":"$@62"}]}]
12:["$","span","code-segment-43",{"style":{},"children":["\n"]}]
13:["$","span","code-segment-44",{"style":{},"children":["        "]}]
14:["$","span","code-segment-45",{"className":"token","style":{"color":"hsl(220, 10%, 40%)","fontStyle":"italic"},"children":["# ... other context stored here"]}]
15:["$","span","code-segment-46",{"style":{},"children":["\n"]}]
16:["$","span","code-segment-48",{"style":{},"children":["    "]}]
17:["$","span","code-segment-49",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["def"]}]
18:["$","span","code-segment-50",{"style":{},"children":[" "]}]
19:["$","span","code-segment-51",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["__iter__"]}]
1a:["$","span","code-segment-52",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}]
1b:["$","span","code-segment-53",{"style":{},"children":["self"]}]
1c:["$","span","code-segment-54",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}]
1d:["$","span","code-segment-55",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}]
1e:["$","span","code-segment-56",{"style":{},"children":["\n"]}]
1f:["$","span","code-segment-57",{"style":{},"children":["        "]}]
20:["$","span","code-segment-58",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["try"]}]
21:["$","span","code-segment-59",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}]
22:["$","span","code-segment-60",{"style":{},"children":["\n"]}]
23:["$","span","code-segment-61",{"style":{},"children":["            "]}]
24:["$","span","code-segment-62",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["for"]}]
25:["$","span","code-segment-63",{"style":{},"children":[" event "]}]
26:["$","span","code-segment-64",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["in"]}]
27:["$","span","code-segment-65",{"style":{},"children":[" self"]}]
28:["$","span","code-segment-66",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}]
29:["$","span","code-segment-67",{"style":{},"children":["_stream"]}]
2a:["$","span","code-segment-68",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}]
2b:["$","span","code-segment-69",{"style":{},"children":["\n"]}]
2c:["$","span","code-segment-70",{"style":{},"children":["                self"]}]
2d:["$","span","code-segment-71",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}]
2e:["$","span","code-segment-72",{"style":{},"children":["_capture"]}]
2f:["$","span","code-segment-73",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}]
30:["$","span","code-segment-74",{"style":{},"children":["event"]}]
31:["$","span","code-segment-75",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}]
32:["$","span","code-segment-76",{"style":{},"children":["   "]}]
33:["$","span","code-segment-77",{"className":"token","style":{"color":"hsl(220, 10%, 40%)","fontStyle":"italic"},"children":["# extract tokens from passing chunks"]}]
34:["$","span","code-segment-78",{"style":{},"children":["\n"]}]
35:["$","span","code-segment-79",{"style":{},"children":["                "]}]
36:["$","span","code-segment-80",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["yield"]}]
37:["$","span","code-segment-81",{"style":{},"children":[" event            "]}]
38:["$","span","code-segment-82",{"className":"token","style":{"color":"hsl(220, 10%, 40%)","fontStyle":"italic"},"children":["# caller sees the event unchanged"]}]
39:["$","span","code-segment-83",{"style":{},"children":["\n"]}]
3a:["$","span","code-segment-84",{"style":{},"children":["        "]}]
3b:["$","span","code-segment-85",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["finally"]}]
3c:["$","span","code-segment-86",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}]
3d:["$","span","code-segment-87",{"style":{},"children":["\n"]}]
3e:["$","span","code-segment-88",{"style":{},"children":["            self"]}]
3f:["$","span","code-segment-89",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}]
40:["$","span","code-segment-90",{"style":{},"children":["_emit_final"]}]
41:["$","span","code-segment-91",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}]
42:["$","span","code-segment-92",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}]
43:["$","span","code-segment-93",{"style":{},"children":["         "]}]
44:["$","span","code-segment-94",{"className":"token","style":{"color":"hsl(220, 10%, 40%)","fontStyle":"italic"},"children":["# fires whether iteration ends or raises"]}]
45:["$","span","code-segment-95",{"style":{},"children":["\n"]}]
46:["$","span","code-segment-97",{"style":{},"children":["    "]}]
47:["$","span","code-segment-98",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["def"]}]
48:["$","span","code-segment-99",{"style":{},"children":[" "]}]
49:["$","span","code-segment-100",{"className":"token","style":{"color":"hsl(207, 82%, 66%)"},"children":["__getattr__"]}]
4a:["$","span","code-segment-101",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}]
4b:["$","span","code-segment-102",{"style":{},"children":["self"]}]
4c:["$","span","code-segment-103",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}]
4d:["$","span","code-segment-104",{"style":{},"children":[" name"]}]
4e:["$","span","code-segment-105",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}]
4f:["$","span","code-segment-106",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[":"]}]
50:["$","span","code-segment-107",{"style":{},"children":["\n"]}]
51:["$","span","code-segment-108",{"style":{},"children":["        "]}]
52:["$","span","code-segment-109",{"className":"token","style":{"color":"hsl(286, 60%, 67%)"},"children":["return"]}]
53:["$","span","code-segment-110",{"style":{},"children":[" "]}]
54:["$","span","code-segment-111",{"className":"token","style":{"color":"hsl(95, 38%, 62%)"},"children":["getattr"]}]
55:["$","span","code-segment-112",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["("]}]
56:["$","span","code-segment-113",{"style":{},"children":["self"]}]
57:["$","span","code-segment-114",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":["."]}]
58:["$","span","code-segment-115",{"style":{},"children":["_stream"]}]
59:["$","span","code-segment-116",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[","]}]
5a:["$","span","code-segment-117",{"style":{},"children":[" name"]}]
5b:["$","span","code-segment-118",{"className":"token","style":{"color":"hsl(220, 14%, 71%)"},"children":[")"]}]
5c:["$","span","code-segment-119",{"style":{},"children":["  "]}]
5d:["$","span","code-segment-120",{"className":"token","style":{"color":"hsl(220, 10%, 40%)","fontStyle":"italic"},"children":["# proxy everything else"]}]
5e:["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-arrow-right ml-2 h-4 w-4","aria-hidden":"true","children":[["$","path","1ays0h",{"d":"M5 12h14"}],["$","path","xquz4c",{"d":"m12 5 7 7-7 7"}],"$undefined"]}]
62:null
