Skip to content

Conversation

@sansyrox
Copy link
Member

@sansyrox sansyrox commented Jun 28, 2025

Description

This PR fixes #1199

Summary

This PR implements server sent events

PR Checklist

Please ensure that:

  • The PR contains a descriptive title
  • The PR contains a descriptive summary of the changes
  • You build and test your changes before submitting a PR.
  • You have added relevant documentation
  • You have added relevant tests. We prefer integration tests wherever possible

Pre-Commit Instructions:

@vercel
Copy link

vercel bot commented Jun 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
robyn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 4, 2025 7:30pm

@sansyrox
Copy link
Member Author

this is a very early implementation with a lot of bugs. need to create a better version when I am not delirious.

@recurseml
Copy link

recurseml bot commented Jun 28, 2025

😱 Found 2 issues. Time to roll up your sleeves! 😱

Need help? Join our Discord for support!
https://discord.gg/NCpkJ4kF

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 2, 2025

CodSpeed Performance Report

Merging #1200 will not alter performance

Comparing feat/sse (f93f291) with main (0a7781d)

Summary

✅ 136 untouched benchmarks
🆕 11 new benchmarks
⁉️ 2 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
⁉️ test_dev_index_request 4.7 ms N/A N/A
⁉️ test_env_population 313.1 µs N/A N/A
🆕 test_sse_async_endpoint N/A 4.5 ms N/A
🆕 test_sse_basic_headers N/A 4.5 ms N/A
🆕 test_sse_basic_stream N/A 4.5 ms N/A
🆕 test_sse_custom_headers N/A 4.5 ms N/A
🆕 test_sse_custom_status_code N/A 4.5 ms N/A
🆕 test_sse_empty_stream N/A 4.5 ms N/A
🆕 test_sse_formatted_messages N/A 4.5 ms N/A
🆕 test_sse_json_data N/A 4.5 ms N/A
🆕 test_sse_middleware_compatibility N/A 4.5 ms N/A
🆕 test_sse_named_events N/A 4.5 ms N/A
🆕 test_sse_single_message N/A 4.5 ms N/A

Comment on lines 46 to 56

# Ensure environment variables are properly set for the subprocess
env = os.environ.copy()
env["ROBYN_HOST"] = domain
env["ROBYN_PORT"] = str(port)

if platform.system() == "Windows":
command[0] = "python"
process = subprocess.Popen(command, shell=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, env=env)
else:
process = subprocess.Popen(command, preexec_fn=os.setsid, env=env)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? Prolly not

@sansyrox
Copy link
Member Author

sansyrox commented Jul 4, 2025

@Recurse-ML re-review

@sansyrox
Copy link
Member Author

sansyrox commented Jul 4, 2025

Quite satisfied with the implementation now. Will write docs.

@sansyrox sansyrox changed the title feat: add server sent responses feat: add server sent events Jul 4, 2025
@sansyrox sansyrox merged commit 89ea747 into main Jul 5, 2025
71 of 74 checks passed
@sansyrox sansyrox deleted the feat/sse branch July 5, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add sse like fast api

2 participants