This library patches starlette, so you can handle "RuntimeError: Caught handled exception, but response already started." exception
Project description
Starlette RAS-handler
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
Usage
-
Define an async function that accepts
(Exception, Request | WebSocket)
and returnsNone
async def print_handler(exc: Exception, request: Request | WebSocket) -> None: print("Caught", exc)
-
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 out an example in /examples/example.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for starlette_ras_handle-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 934a45461deaeaf58df5d773e777a41624145e9e354541ab1670909e6398c303 |
|
MD5 | a16c4d99b6ccff245305c3f1307c2720 |
|
BLAKE2b-256 | 3ef803d70d50c076a2dc009ae236c40dc8380daa5485a3829a4158585a0b3402 |
Close
Hashes for starlette_ras_handle-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82084b1085e6506427cc6432d3262bcd8a5819457512661e4c765486d9c53151 |
|
MD5 | c6ac0726dea333968c8b795875d47105 |
|
BLAKE2b-256 | bd3a73acf8e6b1126d1be7d9173f34c0893b75eeb5f03cd2c81d1a67da401271 |