Browse Source

🎨 Auto format

pull/15357/head
pre-commit-ci-lite[bot] 3 months ago
committed by GitHub
parent
commit
f8b9a65869
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      fastapi/routing.py
  2. 2
      tests/test_background_tasks_merge.py

6
fastapi/routing.py

@ -73,9 +73,9 @@ from fastapi.utils import (
is_body_allowed_for_status_code,
)
from starlette import routing
from starlette.background import BackgroundTasks
from starlette._exception_handler import wrap_app_handling_exceptions
from starlette._utils import is_async_callable
from starlette.background import BackgroundTasks
from starlette.concurrency import iterate_in_threadpool, run_in_threadpool
from starlette.datastructures import FormData
from starlette.exceptions import HTTPException
@ -684,9 +684,7 @@ def get_request_handler(
# Merge injected BackgroundTasks with the Response's
# own background task so neither set is lost.
original = raw_response.background
merged = BackgroundTasks(
solved_result.background_tasks.tasks
)
merged = BackgroundTasks(solved_result.background_tasks.tasks)
if isinstance(original, BackgroundTasks):
merged.tasks.extend(original.tasks)
else:

2
tests/test_background_tasks_merge.py

@ -8,7 +8,7 @@ injected tasks.
See: https://github.com/fastapi/fastapi/issues/11215
"""
from fastapi import FastAPI, BackgroundTasks
from fastapi import BackgroundTasks, FastAPI
from fastapi.testclient import TestClient
from starlette.background import BackgroundTask
from starlette.background import BackgroundTasks as StarletteBackgroundTasks

Loading…
Cancel
Save