|
6 | 6 | from contextlib import AsyncExitStack, asynccontextmanager |
7 | 7 | from inspect import signature |
8 | 8 | from pathlib import Path |
9 | | -from typing import Any, Callable, Mapping, Optional, TypeVar, cast |
| 9 | +from typing import Any, Awaitable, Callable, Mapping, Optional, TypeVar, cast |
10 | 10 |
|
11 | 11 | import starlette.applications |
12 | 12 | import starlette.exceptions |
@@ -57,8 +57,8 @@ class App: |
57 | 57 | returns a UI definition, if you need the UI definition to be created dynamically |
58 | 58 | for each pageview. |
59 | 59 | server |
60 | | - A function which is called once for each session, ensuring that each session is |
61 | | - independent. |
| 60 | + A sync or async function which is called once for each session, ensuring that |
| 61 | + each session is independent. |
62 | 62 | static_assets |
63 | 63 | Static files to be served by the app. If this is a string or Path object, it |
64 | 64 | must be a directory, and it will be mounted at `/`. If this is a dictionary, |
@@ -104,13 +104,13 @@ def server(input: Inputs, output: Outputs, session: Session): |
104 | 104 | """ |
105 | 105 |
|
106 | 106 | ui: RenderedHTML | Callable[[Request], Tag | TagList] |
107 | | - server: Callable[[Inputs, Outputs, Session], None] |
| 107 | + server: Callable[[Inputs, Outputs, Session], Awaitable[None] | None] |
108 | 108 |
|
109 | 109 | def __init__( |
110 | 110 | self, |
111 | 111 | ui: Tag | TagList | Callable[[Request], Tag | TagList] | Path, |
112 | 112 | server: ( |
113 | | - Callable[[Inputs], None] | Callable[[Inputs, Outputs, Session], None] | None |
| 113 | + Callable[[Inputs], Awaitable[None] | None] | Callable[[Inputs, Outputs, Session], Awaitable[None] | None] | None |
114 | 114 | ), |
115 | 115 | *, |
116 | 116 | static_assets: Optional[str | Path | Mapping[str, str | Path]] = None, |
|
0 commit comments