Skip to main content

Starlette RAS-handler

Supported Python versions PyPI version PyPI downloads

This library adds the ability to handle RuntimeError: Caught handled exception, but response already started. error, so you can silent it, or do whatever you want

Installation 📥

python -m pip install -U starlette-ras-handle 

Usage 🛠️

  1. Define an async function that accepts (Exception, Request | WebSocket) and returns None

    async def print_handler(exc: Exception, request: Request | WebSocket) -> None:
        print("Caught", exc)
    
  2. Patch!

    from handler import print_handler
    
    from starlette_ras_handle import handle_starlette_ras
    handle_starlette_ras(print_handler)
    
    # other imports...
    

IMPORTANT: If you want the patch to work properly, you should use it before you import anything, related to starlette (e.g. FastAPI)

You can check an example in /examples/example.py

Troubleshooting 🚨

If you encounter issues or have queries, feel free to check our Issues section on GitHub.

Contribution 🤝

Contributions are welcome. Please fork the repository, make your changes, and submit a pull request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlette_ras_handle-1.0.2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starlette_ras_handle-1.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file starlette_ras_handle-1.0.2.tar.gz.

File metadata

  • Download URL: starlette_ras_handle-1.0.2.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for starlette_ras_handle-1.0.2.tar.gz
Algorithm Hash digest
SHA256 030ffad47257cf13b4e7cbf54e2f5f4069f9d10fb2726d810fe6221d3f262f8f
MD5 92b90813c7d19402d4ea667e74c22a23
BLAKE2b-256 44452f99c28bce9ad78a79099b3468a0a7c0289fbf88cdff6519cfb7935f8460

See more details on using hashes here.

File details

Details for the file starlette_ras_handle-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for starlette_ras_handle-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29671f95475e8422f8627092fb813525fb0ed8a8fbce17caf34075b3bc989d44
MD5 171cc474cc8d3a58951afa0cbf8177cc
BLAKE2b-256 34a239378e85eed41e486f163838700d678ef16060c0d713c71a968cf0767600

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page