Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Nov 19, 2025

Describe your changes

Adds optional support for using uvloop as event loop. uvloop is an ultra-fast, drop-in replacement of the built-in asyncio event loop. This feature will get activated by having uvloop installed.

This change is a preparation for #12772

Testing Plan

  • Added unit test.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13047/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13047.streamlit.app (☁️ Deploy here if not accessible)

@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 19, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@sfc-gh-lmasuch sfc-gh-lmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Nov 19, 2025
@sfc-gh-lmasuch sfc-gh-lmasuch marked this pull request as ready for review November 19, 2025 04:23
@sfc-gh-lmasuch sfc-gh-lmasuch requested a review from a team as a code owner November 19, 2025 04:23
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
lib/setup.py Outdated
# orjson speeds up large plotly figure processing by 5-10x:
"orjson>=3.5.0",
# uvloop speeds up the event loop:
"uvloop>=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')", # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

The environment marker platform_python_implementation should be changed to python_implementation, which is the correct marker name in setuptools. The corrected dependency specification would be:

"uvloop>=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and python_implementation != 'PyPy')"

This ensures proper compatibility checking when the package is installed.

Suggested change
"uvloop>=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')", # noqa: E501
"uvloop>=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and python_implementation != 'PyPy')", # noqa: E501

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds optional support for uvloop, an ultra-fast drop-in replacement for Python's built-in asyncio event loop. When uvloop is installed, Streamlit will automatically use it to improve event loop performance. This is a preparation step for PR #12772.

Key Changes:

  • Automatic uvloop activation when installed (non-Windows platforms only)
  • Graceful fallback to default event loop if uvloop is unavailable or fails to install
  • Comprehensive test coverage for various scenarios (available, missing, Windows, running loop)

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/streamlit/web/bootstrap.py Implements _maybe_install_uvloop() function to conditionally install uvloop as the event loop policy
lib/tests/streamlit/web/bootstrap_test.py Adds test suite for uvloop installation scenarios (available, missing, Windows, running event loop)
lib/setup.py Adds new "performance" optional dependency group containing uvloop (with platform markers) and orjson
lib/test-requirements.txt Adds uvloop>=0.15.1 to test dependencies for testing the integration
mypy.ini Adds mypy configuration to ignore missing uvloop type stubs

@lukasmasuch lukasmasuch merged commit 206d3a9 into develop Nov 24, 2025
42 checks passed
@lukasmasuch lukasmasuch deleted the add-optional-uvloop-support branch November 24, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants