Skip to content

Commit 29cad4d

Browse files
committed
update docstrings
1 parent b04ca14 commit 29cad4d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

taskiq_fastapi/initializator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
from taskiq import AsyncBroker, TaskiqEvents, TaskiqState
66
from taskiq.cli.utils import import_object
77

8+
PathOrAppOrFactory = Union[str, FastAPI, Callable[[], FastAPI]]
9+
810

911
def startup_event_generator(
1012
broker: AsyncBroker,
11-
app_or_path: Union[str, FastAPI],
13+
app_or_path: PathOrAppOrFactory,
1214
) -> Callable[[TaskiqState], Awaitable[None]]:
1315
"""
14-
Generate shutdown event.
16+
Generate startup event handler.
1517
1618
This function takes FastAPI application path
1719
and runs startup event on broker's startup.
1820
1921
:param broker: current broker.
20-
:param app_path: fastapi application path.
22+
:param app_or_path: application path or fastapi instance or callable that creates fastapi app instance.
2123
:returns: startup handler.
2224
"""
2325

@@ -48,7 +50,7 @@ def shutdown_event_generator(
4850
broker: AsyncBroker,
4951
) -> Callable[[TaskiqState], Awaitable[None]]:
5052
"""
51-
Generate shutdown event.
53+
Generate shutdown event handler.
5254
5355
This function takes FastAPI application
5456
and runs shutdown event on broker's shutdown.
@@ -66,7 +68,7 @@ async def shutdown(state: TaskiqState) -> None:
6668
return shutdown
6769

6870

69-
def init(broker: AsyncBroker, app_or_path: Union[str, FastAPI]) -> None:
71+
def init(broker: AsyncBroker, app_or_path: PathOrAppOrFactory) -> None:
7072
"""
7173
Add taskiq startup events.
7274
@@ -78,7 +80,7 @@ def init(broker: AsyncBroker, app_or_path: Union[str, FastAPI]) -> None:
7880
startup events will run.
7981
8082
:param broker: current broker to use.
81-
:param app_path: path to fastapi application.
83+
:param app_or_path: application path or fastapi instance or callable that creates fastapi app instance.
8284
"""
8385
broker.add_event_handler(
8486
TaskiqEvents.WORKER_STARTUP,
@@ -102,7 +104,7 @@ def populate_dependency_context(
102104
This function injects the Request and HTTPConnection
103105
into the broker's dependency context.
104106
105-
It may be need to be called manually if you are using InMemoryBroker.
107+
It may be needed to be called manually if you are using InMemoryBroker.
106108
107109
:param broker: current broker to use.
108110
:param app: current application.

0 commit comments

Comments
 (0)