Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix(worker): Depend on typed SAQ (#33)
Browse files Browse the repository at this point in the history
- depend on SAQ master branch from GH until typed version released
- fix typing for worker module
  • Loading branch information
peterschutt authored Oct 30, 2022
1 parent 4966a3e commit 13d3ac0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
18 changes: 11 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ httpx = "*"
orjson = "*"
pydantic = "*"
redis = "*"
saq = "*"
saq = { git = "https://github.com/tobymao/saq.git" }
sentry-sdk = "*"
sqlalchemy = "==2.0.0b2"
starlite = "~=1.32"
Expand Down
15 changes: 9 additions & 6 deletions src/starlite_saqlalchemy/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
import asyncio
from collections import abc
from functools import partial
from typing import Any
from typing import TYPE_CHECKING, Any

import orjson
import saq # type:ignore[import]
import saq

from . import redis

if TYPE_CHECKING:
from signal import Signals

__all__ = [
"Queue",
"Worker",
Expand All @@ -20,7 +23,7 @@
WorkerFunction = abc.Callable[..., abc.Awaitable[Any]]


class Queue(saq.Queue): # type:ignore[misc]
class Queue(saq.Queue):
"""[SAQ Queue](https://github.com/tobymao/saq/blob/master/saq/queue.py)
Configures `orjson` for JSON serialization/deserialization if not otherwise configured.
Expand All @@ -39,11 +42,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)


class Worker(saq.Worker): # type:ignore[misc]
class Worker(saq.Worker):
"""Modify behavior of saq worker for orchestration by Starlite."""

# same issue: https://github.com/samuelcolvin/arq/issues/182
SIGNALS: list[str] = []
SIGNALS: list["Signals"] = []

async def on_app_startup(self) -> None:
"""Attach the worker to the running event loop."""
Expand All @@ -59,7 +62,7 @@ async def on_app_startup(self) -> None:


def create_worker_instance(
functions: abc.Iterable[WorkerFunction | tuple[str, WorkerFunction]]
functions: abc.Collection[WorkerFunction | tuple[str, WorkerFunction]]
) -> Worker:
"""
Expand Down

0 comments on commit 13d3ac0

Please sign in to comment.