Commit 05460cd
authored
Fix event handling in BamlStream to use non-blocking queue retrieval (#1596)
<!-- ELLIPSIS_HIDDEN -->
> [!IMPORTANT]
> Modify `BamlStream.__aiter__` to use non-blocking queue retrieval with
`get_nowait()` and handle empty queue with `asyncio.sleep()`.
>
> - **Behavior**:
> - In `BamlStream.__aiter__`, change from blocking `queue.get()` to
non-blocking `queue.get_nowait()`.
> - Add `asyncio.sleep(0.050)` in `BamlStream.__aiter__` to handle
`queue.Empty` exception, allowing for non-blocking event retrieval.
> - **Misc**:
> - No changes to `BamlSyncStream` or other parts of `stream.py`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for ff8b656. It will automatically
update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->1 parent 0f2c730 commit 05460cd
1 file changed
+8
-5
lines changedLines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
0 commit comments