You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Incorrect placement of the yield statement in the asynchronous context manager sse_client, causing issues with the lifecycle management of asynchronous tasks and potentially leading to improper resource cleanup.
To Reproduce
Import the sse_client function from the module
Use this function in an async with block to establish an SSE connection
Attempting to exit the context may cause hanging or unexpected behavior
Problems occur with proper resource cleanup (streams, HTTP connections)
Expected behavior
The sse_client context manager should properly initialize the connection, yield communication streams, and correctly close all resources when exiting the context block, regardless of how the context exits (normally or through an exception).
Screenshots
N/A
Additional context
The issue stems from the incorrect nesting structure of asynchronous blocks. Specifically, the yield statement is placed at the wrong nesting level in relation to the task group (anyio.create_task_group()), which disrupts the natural flow of resource management.
The solution involves restructuring the code to first establish the HTTP and SSE connections, and only then start the asynchronous tasks in a group, with the yield statement at the appropriate nesting level, ensuring the correct sequence of resource initialization and cleanup.
Describe the bug
Incorrect placement of the
yield
statement in the asynchronous context managersse_client
, causing issues with the lifecycle management of asynchronous tasks and potentially leading to improper resource cleanup.To Reproduce
sse_client
function from the moduleasync with
block to establish an SSE connectionExpected behavior
The
sse_client
context manager should properly initialize the connection, yield communication streams, and correctly close all resources when exiting the context block, regardless of how the context exits (normally or through an exception).Screenshots
N/A
Additional context
The issue stems from the incorrect nesting structure of asynchronous blocks. Specifically, the
yield
statement is placed at the wrong nesting level in relation to the task group (anyio.create_task_group()
), which disrupts the natural flow of resource management.The solution involves restructuring the code to first establish the HTTP and SSE connections, and only then start the asynchronous tasks in a group, with the
yield
statement at the appropriate nesting level, ensuring the correct sequence of resource initialization and cleanup.sse_py.txt
The text was updated successfully, but these errors were encountered: