Commit 3d051b8
committed
docs: README snippet — drain observer before exit
CoPilot review on PR #36 caught the snippet running invoke() inside
asyncio.run() without awaiting drain(). The CompiledGraph.drain
docstring says drain is the MUST for short-lived scripts because
invoke() returns before the observer delivery queue finishes — the
observer's print lines could fail to fire before the process exits,
defeating the example's whole purpose.
The repo's own observer demo (examples/04-observer-hooks/main.py)
already uses the right pattern: async def main() that awaits
invoke() and then awaits drain() in a try/finally, then
asyncio.run(main()). Match that here. Also drops the unused
``final =`` assignment.
Bumps the preamble line count from "forty lines" to "about fifty
lines" to match what the snippet actually is.1 parent e7c9459 commit 3d051b8
1 file changed
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
134 | 141 | | |
135 | | - | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
0 commit comments