Conversation
Contributor
|
👋 Thanks for your contribution, @NEFORCEO! Please make sure:
Maintainers will review it soon. |
Contributor
Merging this PR will improve performance by 42.09%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_response_req_text_from_json |
213.2 µs | 134.4 µs | +58.66% |
| ⚡ | test_response_repr |
196.4 µs | 131.9 µs | +48.91% |
| ⚡ | test_response_property_access |
194.5 µs | 131.6 µs | +47.8% |
| ⚡ | test_response_json_parsing |
205.6 µs | 141.9 µs | +44.83% |
| ⚡ | test_response_creation |
201.3 µs | 140.1 µs | +43.64% |
| ⚡ | test_middleware_after_response |
403.1 µs | 355.9 µs | +13.28% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/sse (53ec719) with master (6f3d441)1
Footnotes
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚀 Description
Add
@app.sse()decorator for Server-Sent Events (SSE) — real-time event streaming over plain HTTP, alongside the existing HTTP and WebSocket routes.Includes:
fasthttp/sse.py—SSEEventdataclass withevent,data,id,retryfields@app.sse()decorator onFastHTTP— supportsheaders,reconnect,max_retries,tags_run_sse()— async SSE parser usinghttpx.AsyncClientstreaming, parses the standardtext/event-streamformat (data:/event:/id:/: lines)app.run()Last-Event-IDresumptionDocumentation and examples:
docs/en/tutorial/sse/index.md— English tutorial (quick start, API reference, SSE vs WebSocket comparison)docs/ru/tutorial/sse/index.md— Russian tutorialexamples/sse/basic.py— Wikimedia EventStreams real-world exampleexamples/sse/reconnect.py— reconnection example with auth headers🧩 Type of Change
✅ Checklist
🔗 Related Issues
N/A
📸 Additional Context
SSE streams complete alongside HTTP requests — if the server closes the stream, the app exits normally. For infinite streams (e.g. Wikimedia), the app stays alive until Ctrl+C.