ssrshz opened a new issue, #10018: URL: https://github.com/apache/skywalking/issues/10018
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues. ### Apache SkyWalking Component Python Agent (apache/skywalking-python) ### What happened It will have a issue when the app start with the Fastapi, as follows: > INFO: Finished server process [30539] > INFO: Started server process [30544] > INFO: Waiting for application startup. > **INFO: ASGI 'lifespan' protocol appears unsupported.** > INFO: Application startup complete. and the startup and shutdown event will have no effect. ``` @app.on_event("startup") async def init_connect(): db.connect() @app.on_event('shutdown') async def shutdown_connect(): if not db.is_closed(): db.close() ``` So, i debug it, i find that the plugin 'sw_fastapi' doesn't consider the scenario when the scope type is not the http.This bug is not compatible with the uvicorn. When i add the code , it will work. ``` def install(): from starlette.types import Receive, Scope, Send, Message from starlette.exceptions import ExceptionMiddleware _original_fast_api = ExceptionMiddleware.__call__ def params_tostring(params): return '\n'.join([f"{k}=[{','.join(params.getlist(k))}]" for k, _ in params.items()]) async def _sw_fast_api(self, scope: Scope, receive: Receive, send: Send): from starlette.requests import Request **if scope["type"] != "http": await _original_fast_api(self, scope, receive, send) return** req = Request(scope, receive=receive, send=send) carrier = Carrier() method = req.method ``` ### What you expected to happen When i define the startup and shudown event ,they will do ### How to reproduce The scenario is as follows: Fastapi 0.85.1 apache-skywalking 0.8.0 when you use the Fastapi startup and shudown event,it will occur ### Anything else _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
