henry3260 commented on code in PR #65587:
URL: https://github.com/apache/airflow/pull/65587#discussion_r3224564326


##########
airflow-core/src/airflow/api_fastapi/execution_api/app.py:
##########
@@ -300,6 +301,17 @@ def get_extra_schemas() -> dict[str, dict]:
     }
 
 
+class _RequestScopedServerContextApp:
+    """Wrap an ASGI app so in-process requests behave like server-side API 
handling."""
+
+    def __init__(self, app: FastAPI) -> None:
+        self.app = app
+
+    async def __call__(self, scope: Any, receive: Any, send: Any) -> None:
+        with override_process_context("server"):
+            await self.app(scope, receive, send)

Review Comment:
   > If we override the `ContextVar` to `server` but the 
`airflow.sdk.execution_time.task_runner.SUPERVISOR_COMMS` hasn't been 
initialized. It seems we will still encounter the same issue.
   
   `test_in_process_execution_api_uses_request_scoped_server_context` also 
covers the scenario where the outer process already has `SUPERVISOR_COMMS `set, 
and verifies that the in-process Execution API request is still handled in 
server contex



-- 
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]

Reply via email to