- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 50 for anyio (0.02 seconds)
-
fastapi/concurrency.py
from collections.abc import AsyncGenerator from contextlib import AbstractContextManager from contextlib import asynccontextmanager as asynccontextmanager from typing import TypeVar import anyio.to_thread from anyio import CapacityLimiter from starlette.concurrency import iterate_in_threadpool as iterate_in_threadpool # noqa from starlette.concurrency import run_in_threadpool as run_in_threadpool # noqa from starlette.concurrency import ( # noqa
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 1.5K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/async-tests.md
你已經看過如何使用提供的 `TestClient` 來測試你的 FastAPI 應用。到目前為止,你只看到如何撰寫同步測試,沒有使用 `async` 函式。 在測試中能使用非同步函式會很有用,例如當你以非同步方式查詢資料庫時。想像你想測試發送請求到 FastAPI 應用,然後在使用非同步資料庫函式庫時,驗證後端是否成功把正確資料寫入資料庫。 來看看怎麼做。 ## pytest.mark.anyio { #pytest-mark-anyio } 若要在測試中呼叫非同步函式,測試函式本身也必須是非同步的。AnyIO 為此提供了一個好用的外掛,讓我們可以標示某些測試函式以非同步方式執行。 ## HTTPX { #httpx } 即使你的 FastAPI 應用使用一般的 `def` 函式而非 `async def`,它在底層仍然是個 `async` 應用。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 3.5K bytes - Click Count (0) -
docs_src/custom_response/tutorial007_py310.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 19:12:46 GMT 2026 - 319 bytes - Click Count (0) -
docs/zh/docs/advanced/async-tests.md
在测试中能够使用异步函数可能会很有用,比如当您需要异步查询数据库的时候。想象一下,您想要测试向 FastAPI 应用程序发送请求,然后验证您的后端是否成功在数据库中写入了正确的数据,与此同时您使用了异步的数据库的库。 让我们看看如何才能实现这一点。 ## pytest.mark.anyio { #pytest-mark-anyio } 如果我们想在测试中调用异步函数,那么我们的测试函数必须是异步的。 AnyIO 为此提供了一个简洁的插件,它允许我们指定一些测试函数要异步调用。 ## HTTPX { #httpx } 即使您的 **FastAPI** 应用程序使用普通的 `def` 函数而不是 `async def` ,它本质上仍是一个 `async` 异步应用程序。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 3.9K bytes - Click Count (0) -
docs/en/docs/advanced/async-tests.md
Let's look at how we can make that work. ## pytest.mark.anyio { #pytest-mark-anyio } If we want to call asynchronous functions in our tests, our test functions have to be asynchronous. AnyIO provides a neat plugin for this, that allows us to specify that some test functions are to be called asynchronously. ## HTTPX { #httpx }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 3.8K bytes - Click Count (0) -
tests/test_list_bytes_file_order_preserved_issue_14811.py
""" Regression test: preserve order when using list[bytes] + File() See https://github.com/fastapi/fastapi/discussions/14811 Fixed in PR: https://github.com/fastapi/fastapi/pull/14884 """ from typing import Annotated import anyio import pytest from fastapi import FastAPI, File from fastapi.testclient import TestClient from starlette.datastructures import UploadFile as StarletteUploadFile def test_list_bytes_file_preserves_order(
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 10 12:14:38 GMT 2026 - 1.4K bytes - Click Count (0) -
tests/test_stream_cancellation.py
Ref: https://github.com/fastapi/fastapi/issues/14680 """ from collections.abc import AsyncIterable import anyio import pytest from fastapi import FastAPI from fastapi.responses import StreamingResponse pytestmark = [ pytest.mark.anyio, pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning"), ] app = FastAPI()Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 18:56:47 GMT 2026 - 2.7K bytes - Click Count (0) -
docs/ja/docs/advanced/async-tests.md
テストで非同期関数を使えると、たとえばデータベースへ非同期にクエリする場合などに便利です。非同期データベースライブラリを使いながら、FastAPI アプリにリクエストを送り、その後バックエンドが正しいデータをデータベースに書き込めたかを検証したい、といったケースを想像してください。 その方法を見ていきます。 ## pytest.mark.anyio { #pytest-mark-anyio } テスト内で非同期関数を呼び出したい場合、テスト関数自体も非同期である必要があります。AnyIO はこれを実現するための便利なプラグインを提供しており、特定のテスト関数を非同期で呼び出すことを指定できます。 ## HTTPX { #httpx } **FastAPI** アプリケーションが通常の `def` 関数を使っていても、その内側は依然として `async` アプリケーションです。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 4.5K bytes - Click Count (0) -
fastapi/.agents/skills/fastapi/references/streaming.md
def stream_image_no_async_no_annotation(): with read_image() as image_file: yield from image_file ``` prefer this over returning a `StreamingResponse` directly: ```python # DO NOT DO THIS import anyio from fastapi import FastAPI from fastapi.responses import StreamingResponse from app.utils import read_image app = FastAPI() class PNGStreamingResponse(StreamingResponse): media_type = "image/png"
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 10:05:57 GMT 2026 - 2.5K bytes - Click Count (0) -
fastapi/.agents/skills/fastapi/references/other-tools.md
## ty If ty is available, use it to check types. ## Asyncer When needing to run blocking code inside of async functions, or async code inside of blocking functions, suggest using Asyncer. Prefer it over AnyIO or asyncio. Install: ```bash uv add asyncer ``` Run blocking sync code inside of async with `asyncify()`: ```python from asyncer import asyncify from fastapi import FastAPI
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 10:05:57 GMT 2026 - 1.5K bytes - Click Count (0)