Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# Documented in https://zulip.readthedocs.io/en/latest/subsystems/queuing.html
|
|
import importlib
|
|
import pkgutil
|
|
|
|
from django.conf import settings
|
|
|
|
import zerver.worker
|
|
from zerver.worker.base import QueueProcessingWorker, test_queues, worker_classes
|
|
|
|
|
|
def get_worker(
|
|
queue_name: str,
|
|
*,
|
|
threaded: bool = False,
|
|
disable_timeout: bool = False,
|
|
worker_num: int | None = None,
|
|
) -> QueueProcessingWorker:
|
|
if queue_name in {"test", "noop", "noop_batch"}:
|
|
import_module = "zerver.worker.test"
|
|
else:
|
|
import_module = f"zerver.worker.{queue_name}"
|
|
|
|
importlib.import_module(import_module)
|
|
return worker_classes[queue_name](
|
|
threaded=threaded, disable_timeout=disable_timeout, worker_num=worker_num
|
|
)
|
|
|
|
|
|
def get_active_worker_queues(only_test_queues: bool = False) -> list[str]:
|
|
"""Returns the worker queues that should run on this server, honoring
|
|
configuration that gates a queue on a setting."""
|
|
for module_info in pkgutil.iter_modules(zerver.worker.__path__, "zerver.worker."):
|
|
importlib.import_module(module_info.name)
|
|
|
|
queues = [
|
|
queue_name
|
|
for queue_name in worker_classes
|
|
if bool(queue_name in test_queues) == only_test_queues
|
|
]
|
|
if not settings.DEDICATED_SOFT_REACTIVATION_QUEUE:
|
|
# Soft reactivations share the deferred_work queue unless a server
|
|
# opts into a dedicated queue, so its worker is not run otherwise.
|
|
queues = [queue_name for queue_name in queues if queue_name != "soft_reactivation"]
|
|
return queues
|