Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions temporallib/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from temporalio.worker import SharedStateManager, WorkflowRunner
from temporalio.worker.workflow_sandbox import SandboxedWorkflowRunner
from temporalio.worker._workflow_instance import UnsandboxedWorkflowRunner
from temporalio.client import Client as TemporalClient
from temporalio.client import Interceptor, OutboundInterceptor
from collections import defaultdict

Expand All @@ -29,12 +30,12 @@ class WorkerOptions:

class Worker(TemporalWorker):
"""
A class which wraps the :class:`temporalio.client.Client` class
A class which wraps the :class:`temporalio.worker.Worker` class
"""

def __init__(
self,
client: Client,
client: Client | TemporalClient,
Copy link
Contributor

@kelkawi-a kelkawi-a Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe Python 3.8 doesn't support |, you'd need to use from typing import Union and do Union[Client, TemporalClient]. Could you please test the lib locally with a sample workflow run to ensure it works as intended?

General note: we could do with an integration test for this lib.

task_queue: Optional[str] = None,
workflows: Sequence[Type] = [],
activities: Sequence[Callable] = [],
Expand Down Expand Up @@ -64,14 +65,16 @@ def __init__(
debug_mode: bool = False,
disable_eager_activity_execution: bool = False,
on_fatal_error: Optional[Callable[[BaseException], Awaitable[None]]] = None,
use_worker_versioning: bool=False,
use_worker_versioning: bool = False,
):
if interceptors is None:
interceptors = []

self._task_queue = task_queue or os.getenv("TEMPORAL_QUEUE")
if not self._task_queue:
raise ValueError("task_queue must be provided either as a parameter or an environment variable.")
raise ValueError(
"task_queue must be provided either as a parameter or an environment variable."
)

if worker_opt:
if worker_opt.sentry and worker_opt.sentry.dsn:
Expand Down