Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Danitegue opened this issue May 20, 2024 · 1 comment

Comments

@Danitegue
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant