Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 161 - 170 of 1,038 for Async (0.02 seconds)

  1. docs/zh/docs/advanced/stream-data.md

    ### 文件与异步 { #files-and-async }
    
    大多数情况下,类文件对象默认与 async 和 await 不兼容。
    
    例如,它们没有 `await file.read()`,也不支持 `async for chunk in file`。
    
    而且很多情况下,读取它们是一个阻塞操作(可能会阻塞事件循环),因为数据来自磁盘或网络。
    
    /// info | 信息
    
    上面的示例其实是个例外,因为 `io.BytesIO` 对象已经在内存中,所以读取它不会阻塞。
    
    但在许多情况下,读取文件或类文件对象会发生阻塞。
    
    ///
    
    为避免阻塞事件循环,你可以简单地把*路径操作函数*声明为常规的 `def`(而不是 `async def`),这样 FastAPI 会在一个线程池工作线程上运行它,从而避免阻塞主事件循环。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:29:48 GMT 2026
    - 5.2K bytes
    - Click Count (0)
  2. docs_src/security/tutorial002_an_py310.py

        return User(
            username=token + "fakedecoded", email="******@****.***", full_name="John Doe"
        )
    
    
    async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):
        user = fake_decode_token(token)
        return user
    
    
    @app.get("/users/me")
    async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 761 bytes
    - Click Count (0)
  3. docs/en/docs/js/termynal.js

    /**
     * termynal.js
     * A lightweight, modern and extensible animated terminal window, using
     * async/await.
     *
     * @author Ines Montani <******@****.***>
     * @version 0.0.1
     * @license MIT
     */
    
    'use strict';
    
    /** Generate a terminal widget. */
    class Termynal {
        /**
         * Construct the widget's settings.
         * @param {(string|Node)=} container - Query selector or container element.
         * @param {Object=} options - Custom settings.
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Aug 31 10:32:57 GMT 2025
    - 9.3K bytes
    - Click Count (0)
  4. docs/zh/docs/tutorial/server-sent-events.md

    /// tip | 提示
    
    由于 Pydantic 会在**Rust** 端序列化它,相比未声明返回类型,你将获得更高的**性能**。
    
    ///
    
    ### 非 async 的*路径操作函数* { #non-async-path-operation-functions }
    
    你也可以使用常规的 `def` 函数(没有 `async`),并以同样的方式使用 `yield`。
    
    FastAPI 会确保其正确运行,从而不阻塞事件循环。
    
    由于此时函数不是 async,正确的返回类型应为 `Iterable[Item]`:
    
    {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[28:31] hl[29] *}
    
    ### 无返回类型 { #no-return-type }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:29:48 GMT 2026
    - 4.6K bytes
    - Click Count (0)
  5. tests/test_request_params/test_body/test_required_str.py

    # Without aliases
    
    
    @app.post("/required-str", operation_id="required_str")
    async def read_required_str(p: Annotated[str, Body(embed=True)]):
        return {"p": p}
    
    
    class BodyModelRequiredStr(BaseModel):
        p: str
    
    
    @app.post("/model-required-str", operation_id="model_required_str")
    async def read_model_required_str(p: BodyModelRequiredStr):
        return {"p": p.p}
    
    
    @pytest.mark.parametrize(
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 10.9K bytes
    - Click Count (0)
  6. tests/test_request_params/test_file/test_optional_list.py

    # Without aliases
    
    
    @app.post("/optional-list-bytes")
    async def read_optional_list_bytes(p: Annotated[list[bytes] | None, File()] = None):
        return {"file_size": [len(file) for file in p] if p else None}
    
    
    @app.post("/optional-list-uploadfile")
    async def read_optional_list_uploadfile(
        p: Annotated[list[UploadFile] | None, File()] = None,
    ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Feb 21 13:01:31 GMT 2026
    - 10.8K bytes
    - Click Count (0)
  7. tests/test_request_params/test_header/test_optional_list.py

    # Without aliases
    
    
    @app.get("/optional-list-str")
    async def read_optional_list_str(
        p: Annotated[list[str] | None, Header()] = None,
    ):
        return {"p": p}
    
    
    class HeaderModelOptionalListStr(BaseModel):
        p: list[str] | None = None
    
    
    @app.get("/model-optional-list-str")
    async def read_model_optional_list_str(
        p: Annotated[HeaderModelOptionalListStr, Header()],
    ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 9.6K bytes
    - Click Count (0)
  8. src/test/java/jcifs/internal/smb2/Smb2EchoResponseTest.java

            statusField.setInt(smb, status);
        }
    
        private void setAsync(ServerMessageBlock2 smb, boolean async) throws Exception {
            Field asyncField = ServerMessageBlock2.class.getDeclaredField("async");
            asyncField.setAccessible(true);
            asyncField.setBoolean(smb, async);
        }
    Created: Sun Apr 05 00:10:12 GMT 2026
    - Last Modified: Thu Aug 14 05:31:44 GMT 2025
    - 15.1K bytes
    - Click Count (0)
  9. fastapi/routing.py

        async def app(scope: Scope, receive: Receive, send: Send) -> None:
            session = WebSocket(scope, receive=receive, send=send)
    
            async def app(scope: Scope, receive: Receive, send: Send) -> None:
                async with AsyncExitStack() as request_stack:
                    scope["fastapi_inner_astack"] = request_stack
                    async with AsyncExitStack() as function_stack:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 193K bytes
    - Click Count (0)
  10. fastapi/security/http.py

            return HTTPException(
                status_code=HTTP_401_UNAUTHORIZED,
                detail="Not authenticated",
                headers=self.make_authenticate_headers(),
            )
    
        async def __call__(self, request: Request) -> HTTPAuthorizationCredentials | None:
            authorization = request.headers.get("Authorization")
            scheme, credentials = get_authorization_scheme_param(authorization)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Mar 16 10:16:48 GMT 2026
    - 13.1K bytes
    - Click Count (0)
Back to Top