22
33from dataclasses import dataclass , field
44from pathlib import Path
5- from typing import TYPE_CHECKING , Callable , Collection , Dict , Mapping , TypeVar , Union , cast
5+ from typing import TYPE_CHECKING , Callable , Collection , Dict , Literal , Mapping , TypeVar , Union , cast
66
77from litestar .exceptions import ImproperlyConfiguredException
88from litestar .serialization import decode_json , encode_json
@@ -40,7 +40,7 @@ def serializer(value: Any) -> str:
4040
4141
4242def _get_static_files () -> Path :
43- return Path (module_to_os_path ("saq.web" ) / "static" )
43+ return Path (module_to_os_path ("saq" ) / "web" / "static" )
4444
4545
4646@dataclass
@@ -80,8 +80,7 @@ class SAQConfig:
8080
8181 Default is set to 1.
8282 """
83- web_enabled : bool = False
84- """If true, the worker admin UI is launched on worker startup.."""
83+
8584 json_deserializer : LoadType = decode_json
8685 """This is a Python callable that will
8786 convert a JSON string to a Python object. By default, this is set to Litestar's
@@ -91,10 +90,16 @@ class SAQConfig:
9190 By default, Litestar's :attr:`encode_json() <.serialization.encode_json>` is used."""
9291 static_files : Path = field (default_factory = _get_static_files )
9392 """Location of the static files to serve for the SAQ UI"""
93+ web_enabled : bool = False
94+ """If true, the worker admin UI is launched on worker startup.."""
9495 web_path = "/saq"
9596 """Base path to serve the SAQ web UI"""
9697 web_guards : list [Guard ] | None = field (default = None )
9798 """Guards to apply to web endpoints."""
99+ web_include_in_schema : bool = True
100+ """Include Queue API endpoints in generated OpenAPI schema"""
101+ use_server_lifespan : bool = False
102+ """Utilize the server lifespan hook to run SAQ."""
98103
99104 def __post_init__ (self ) -> None :
100105 if self .redis is not None and self .redis_url is not None :
@@ -189,7 +194,7 @@ class QueueConfig:
189194 concurrency : int = 10
190195 """Number of jobs to process concurrently"""
191196 max_concurrent_ops : int = 15
192- """Maximum concurrent operations. (default 20 )
197+ """Maximum concurrent operations. (default 15 )
193198 This throttles calls to `enqueue`, `job`, and `abort` to prevent the Queue
194199 from consuming too many Redis connections."""
195200 tasks : Collection [ReceivesContext | tuple [str , Function ] | str ] = field (default_factory = list )
@@ -212,6 +217,9 @@ class QueueConfig:
212217 abort: how often to check if a job is aborted"""
213218 dequeue_timeout : float = 0
214219 """How long it will wait to dequeue"""
220+ multiprocessing_mode : Literal ["multiprocessing" , "threading" ] = "multiprocessing"
221+ """Executes with the multiprocessing or threading backend.
222+ Set it threading for workloads that aren't CPU bound."""
215223 separate_process : bool = True
216224 """Executes as a separate event loop when True.
217225 Set it False to execute within the Litestar application."""
0 commit comments