temporalio / documentation

Temporal documentation
https://docs.temporal.io
Other
85 stars 224 forks source link

TypeError: Worker.__init__() got an unexpected keyword argument 'namespace' #2842

Open Danitegue opened 4 months ago

Danitegue commented 4 months ago

When I run the backgroundcheck_dacx.py example worker, following the instructions at:

https://docs.temporal.io/dev-guide/python/project-setup#dev-server-worker

I get this error:

TypeError: Worker.init() got an unexpected keyword argument 'namespace'

The problem happens at the initialization of the worker:

worker = Worker(
    client,
    namespace="backgroundcheck_namespace",
    task_queue="backgroundcheck-boilerplate-task-queue",
    workflows=[BackgroundCheck],
    activities=[ssn_trace_activity],
)

Here, "namespace" is not a valid argument. There is no "namespace" in the init function of the worker object, at the python module temporalio v1.6.0 (venv/lib/python3.10/site-packages/temporalio/worker/_worker.py)

Danitegue commented 4 months ago

In the web docs, https://docs.temporal.io/dev-guide/python/project-setup#dev-server-worker

async def main():
    client = await Client.connect("localhost:7233", namespace="backgroundcheck_namespace")

    worker = Worker(
        client,
        namespace="backgroundcheck_namespace",
        task_queue="backgroundcheck-boilerplate-task-queue",
        workflows=[BackgroundCheck],
        activities=[ssn_trace_activity],
    )

(We can see, how the namespace is bundled into the client.)

But in the respective file of the docummentation repository: https://github.com/temporalio/documentation-samples-python/blob/main/backgroundcheck_boilerplate/dev_server_worker/main_dacx.py

The content is different:

async def main():
    client = await Client.connect("localhost:7233")

    worker = Worker(
        client,
        namespace="backgroundcheck_namespace",
        task_queue="backgroundcheck-boilerplate-task-queue",
        workflows=[BackgroundCheck],
        activities=[ssn_trace_activity],
    )

(we specify a namespace when instantiating the Worker)

I suppose it is needed to update both: -in the example file, it is needed to add the namespace argument when connecting to the client. And delete the namespace argument when instantiating the Worker. -in the web docs, remove the namespace argument when instantiating the worker.