Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 31 - 40 of 1,038 for Async (0.03 seconds)

  1. fastapi/.agents/skills/fastapi/SKILL.md

    ## Async vs Sync *path operations*
    
    Use `async` *path operations* only when fully certain that the logic called inside is compatible with async and await (it's called with `await`) or that doesn't block.
    
    ```python
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    # Use async def when calling async code
    @app.get("/async-items/")
    async def read_async_items():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 10:05:57 GMT 2026
    - 10.1K bytes
    - Click Count (0)
  2. tests/test_multipart_installation.py

            monkeypatch.delattr("multipart.multipart.parse_options_header", raising=False)
        with pytest.raises(RuntimeError, match=multipart_incorrect_install_error):
            app = FastAPI()
    
            @app.post("/")
            async def root(username: str = Form()):
                return username  # pragma: nocover
    
    
    def test_incorrect_multipart_installed_file_upload(monkeypatch):
        monkeypatch.setattr("python_multipart.__version__", "0.0.12")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Oct 27 21:46:26 GMT 2024
    - 5.7K bytes
    - Click Count (0)
  3. tests/test_router_events.py

    
    def test_merged_mixed_state_lifespans() -> None:
        @asynccontextmanager
        async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
            yield
    
        @asynccontextmanager
        async def router_lifespan(app: FastAPI) -> AsyncGenerator[dict[str, bool], None]:
            yield {"router": True}
    
        @asynccontextmanager
        async def sub_router_lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
            yield
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 11.7K bytes
    - Click Count (0)
  4. tests/test_ambiguous_params.py

            @app.get("/items/{item_id}/")
            async def get_item(item_id: Annotated[int, Path(default=1)]):
                pass  # pragma: nocover
    
        with pytest.raises(
            AssertionError,
            match=(
                "`Query` default value cannot be set in `Annotated` for 'item_id'. Set the"
                " default value with `=` instead."
            ),
        ):
    
            @app.get("/")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Dec 20 15:55:38 GMT 2025
    - 2K bytes
    - Click Count (1)
  5. android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java

      public void testCancel_beforeSet() throws Exception {
        SettableFuture<Object> async = SettableFuture.create();
        async.cancel(true);
        assertFalse(async.set(42));
      }
    
      public void testCancel_multipleBeforeSetFuture_noInterruptFirst() throws Exception {
        SettableFuture<Object> async = SettableFuture.create();
        async.cancel(false);
        async.cancel(true);
        SettableFuture<Object> inner = SettableFuture.create();
    Created: Fri Apr 03 12:43:13 GMT 2026
    - Last Modified: Mon Mar 16 22:45:21 GMT 2026
    - 7.4K bytes
    - Click Count (0)
  6. fastapi/datastructures.py

    
        @app.post("/files/")
        async def create_file(file: Annotated[bytes, File()]):
            return {"file_size": len(file)}
    
    
        @app.post("/uploadfile/")
        async def create_upload_file(file: UploadFile):
            return {"filename": file.filename}
        ```
        """
    
        file: Annotated[
            BinaryIO,
            Doc("The standard Python file object (non-async)."),
        ]
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 5.2K bytes
    - Click Count (0)
  7. tests/test_sse.py

    keepalive_app = FastAPI()
    
    
    @keepalive_app.get("/slow-async", response_class=EventSourceResponse)
    async def slow_async_stream():
        yield {"n": 1}
        # Sleep longer than the (monkeypatched) ping interval so a keepalive
        # comment is emitted before the next item.
        await asyncio.sleep(0.3)
        yield {"n": 2}
    
    
    @keepalive_app.get("/slow-sync", response_class=EventSourceResponse)
    def slow_sync_stream():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 09:21:52 GMT 2026
    - 9.8K bytes
    - Click Count (0)
  8. docs_src/stream_data/tutorial001_py310.py

    async def stream_story_no_annotation():
        for line in message.splitlines():
            yield line
    
    
    @app.get("/story/stream-no-async-no-annotation", response_class=StreamingResponse)
    def stream_story_no_async_no_annotation():
        for line in message.splitlines():
            yield line
    
    
    @app.get("/story/stream-bytes", response_class=StreamingResponse)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 18:56:47 GMT 2026
    - 2.2K bytes
    - Click Count (0)
  9. docs/en/docs/advanced/events.md

    The first thing to notice, is that we are defining an async function with `yield`. This is very similar to Dependencies with `yield`.
    
    {* ../../docs_src/events/tutorial003_py310.py hl[14:19] *}
    
    The first part of the function, before the `yield`, will be executed **before** the application starts.
    
    And the part after the `yield` will be executed **after** the application has finished.
    
    ### Async Context Manager { #async-context-manager }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 7.8K bytes
    - Click Count (0)
  10. docs_src/stream_json_lines/tutorial001_py310.py

    ]
    
    
    @app.get("/items/stream")
    async def stream_items() -> AsyncIterable[Item]:
        for item in items:
            yield item
    
    
    @app.get("/items/stream-no-async")
    def stream_items_no_async() -> Iterable[Item]:
        for item in items:
            yield item
    
    
    @app.get("/items/stream-no-annotation")
    async def stream_items_no_annotation():
        for item in items:
            yield item
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 18:56:47 GMT 2026
    - 936 bytes
    - Click Count (0)
Back to Top