-
-
Notifications
You must be signed in to change notification settings - Fork 485
feat: sse ping_interval events #4098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RenameMe1
wants to merge
29
commits into
litestar-org:main
Choose a base branch
from
RenameMe1:sse_timeout_events
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+323
−4
Open
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2c7fdd9
added ping_interval keyword
RenameMe1 65e97f7
created _send_ping_event method
RenameMe1 0d051b3
added _send_ping_event in task_group
RenameMe1 381a1ea
Conveted the ping_interval type to a float
RenameMe1 01c188c
Changed doc string to ping_interval
RenameMe1 22ac9aa
Update _send_ping_event doc string
RenameMe1 9acda57
added new sse example with `ping_interval`
RenameMe1 cbe9e48
added `event:` in ping body
RenameMe1 7018a69
added test case sse response with ping events
RenameMe1 08f84d7
lint updated
RenameMe1 8e9bd4c
Merge branch 'main' into sse_timeout_events
RenameMe1 6c6a00c
added ping events test case in test_sse.py
RenameMe1 76d0aae
added type hint
RenameMe1 23a8455
Merge branch 'main' into sse_timeout_events
RenameMe1 385d8fc
Merge branch 'litestar-org:main' into sse_timeout_events
RenameMe1 642d3f6
removed ping_event from ASGIStreamingResponse, added stop if the SSE …
RenameMe1 c0798be
added test for negative number for ping_interval
RenameMe1 0b5f8f0
Merge branch 'main' into sse_timeout_events
RenameMe1 174bc0f
Merge branch 'litestar-org:main' into sse_timeout_events
RenameMe1 9429e83
Change doc message to ASGIStreamingSSEResponse
RenameMe1 b7e7bc1
added a more informative description of `ping_interval`
RenameMe1 372e891
pre-commit update
RenameMe1 10e805e
Added anyio.Event to stop sending ping events
RenameMe1 e6aa91c
update doc to __init__
RenameMe1 4f4ff27
extra spaces have been removed
RenameMe1 75ee8ba
transferring the code to sse.py
RenameMe1 c00ff86
slots update
RenameMe1 5d744f2
decreased ping_interval to test case
RenameMe1 165dd59
fix docs warning
RenameMe1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from asyncio import sleep | ||
| from typing import AsyncGenerator | ||
|
|
||
| from litestar import Litestar, get | ||
| from litestar.response import ServerSentEvent, ServerSentEventMessage | ||
| from litestar.types import SSEData | ||
|
|
||
| async def my_slow_generator() -> AsyncGenerator[SSEData, None]: | ||
| count = 0 | ||
| while count < 1: | ||
| await sleep(1) | ||
| count += 1 | ||
| yield ServerSentEventMessage(data="content", event="message") | ||
|
|
||
| @get(path="/with_ping", sync_to_thread=False) | ||
| def sse_handler_with_ping_events() -> ServerSentEvent: | ||
| return ServerSentEvent(my_slow_generator(), ping_interval=0.1) | ||
|
|
||
|
|
||
| app = Litestar(route_handlers=[sse_handler_with_ping_events]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.