Camunda 8 Self-Managed in Docker with Python Task Service

Please refer to this github repository.

My goal is to use an external python worker to carry out a service task in a self-managed Camunda 8 deployment based in Docker. I have used the template docker-compose.yaml file to successfully deploy the self-managed Camunda, and can connect to Operate and Tasklist to see my deployed process. However, when I run docker-compose up --build in the python-worker directory (after Camunda is up and running) I get the following output:

[+] Building 0.5s (10/10) FINISHED                                                                                       docker:desktop-linux
 => [python-worker internal] load build definition from Dockerfile                                                                       0.0s
 => => transferring dockerfile: 209B                                                                                                     0.0s
 => [python-worker internal] load metadata for docker.io/library/python:3.8-slim                                                         0.4s
 => [python-worker internal] load .dockerignore                                                                                          0.0s
 => => transferring context: 2B                                                                                                          0.0s
 => [python-worker 1/5] FROM docker.io/library/python:3.8-slim@sha256:2f911e2866173a52104dc16b5e42b7069c2eba05eb78556d18b1ca665d0dc445   0.0s
 => [python-worker internal] load build context                                                                                          0.0s
 => => transferring context: 1.12kB                                                                                                      0.0s
 => CACHED [python-worker 2/5] WORKDIR /app                                                                                              0.0s
 => CACHED [python-worker 3/5] COPY requirements.txt .                                                                                   0.0s
 => CACHED [python-worker 4/5] RUN pip install -r requirements.txt                                                                       0.0s
 => [python-worker 5/5] COPY . .                                                                                                         0.0s
 => [python-worker] exporting to image                                                                                                   0.0s
 => => exporting layers                                                                                                                  0.0s
 => => writing image sha256:14e4179a401e1bab31091daeb4fe7d270bcfdc5c13f9022d069a292cb730452c                                             0.0s
 => => naming to docker.io/library/python-workers-python-worker                                                                          0.0s
[+] Running 0/1
 â ‹ Container python-workers-python-worker-1  Recreated                                                                                   0.1s 
Attaching to python-worker-1
python-worker-1  | Starting worker
python-worker-1  | <grpc.aio._channel.Channel object at 0xffffa548a850>
python-worker-1  | <pyzeebe.worker.worker.ZeebeWorker object at 0xffffa5485b50>
python-worker-1  | about to start the loop
python-worker-1  | in the try catch thing
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | WARNING:pyzeebe.worker.job_poller:Failed to activate jobs from the gateway. Exception: ZeebeGatewayUnavailableError(). Retrying in 5 seconds...
python-worker-1  | about to close
python-worker-1  | Traceback (most recent call last):
python-worker-1  |   File "app.py", line 28, in <module>
python-worker-1  |     main()
python-worker-1  |   File "app.py", line 21, in main
python-worker-1  |     loop.run_until_complete(worker.work())
python-worker-1  |   File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
python-worker-1  |     return future.result()
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/worker.py", line 93, in work
python-worker-1  |     await self._work_task
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py", line 39, in poll
python-worker-1  |     await self.activate_max_jobs()
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py", line 43, in activate_max_jobs
python-worker-1  |     await self.poll_once()
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py", line 62, in poll_once
python-worker-1  |     async for job in jobs:
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/grpc_internals/zeebe_job_adapter.py", line 39, in activate_jobs
python-worker-1  |     async for response in self._gateway_stub.ActivateJobs(
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/grpc/aio/_channel.py", line 196, in __call__
python-worker-1  |     call = UnaryStreamCall(
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/grpc/aio/_call.py", line 621, in __init__
python-worker-1  |     channel.call(method, deadline, credentials, wait_for_ready),
python-worker-1  |   File "src/python/grpcio/grpc/_cython/_cygrpc/aio/channel.pyx.pxi", line 124, in grpc._cython.cygrpc.AioChannel.call
python-worker-1  | grpc._cython.cygrpc.UsageError: Channel is closed.
python-worker-1  | Exception ignored in: <coroutine object JobExecutor.execute at 0xffffa2d216c0>
python-worker-1  | Traceback (most recent call last):
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/job_executor.py", line 25, in execute
python-worker-1  |   File "/usr/local/lib/python3.8/site-packages/pyzeebe/worker/job_executor.py", line 30, in get_next_job
python-worker-1  |   File "/usr/local/lib/python3.8/asyncio/queues.py", line 165, in get
python-worker-1  |   File "/usr/local/lib/python3.8/asyncio/base_events.py", line 719, in call_soon
python-worker-1  |   File "/usr/local/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
python-worker-1  | RuntimeError: Event loop is closed
python-worker-1 exited with code 1

Essentially, the python worker does not seem to recognize my deployed Zeebe gateway, and after trying to connect 10 times unsuccessfully it times out and shuts down.

All settings and environment variables are specified in the repository mentioned above. Also, I recognize that this may be an issue with the pyzeebe package which has not had an update in almost two years. However, I would really appreciate any insight or thoughts on this issue.

I am a beginner in both Camunda and Docker, so my error may be in something basic as well. Thank you in advance for your help!

Hi @Spencer_Matthews, welcome to the forums! Two quick things to look at:

  1. I am not a Docker expert, so I don’t know if how you’ve configured the camunda-platform network in the Python docker-compose.yaml is correct. It looks like you are renaming the network, which might mean the Python container is on a different virtual network than Camunda.
  2. You are using localhost as the host in your Python worker, however that will only look at the container it’s running in. If the container is on the same network as Camunda, then you should be able to use zeebe:26500 instead (have a look at the configuration in Camunda’s docker-compose.yaml, for instance).

@nathan.loding thank you so much! Sometimes it just takes another pair of eyes. Changing localhost to zeebe in my app.py file fixed the issue. Love it when it’s that easy, and I really appreciate your time looking into this!

As a side note, do you think have an example repository like the one I shared for self-managed on docker would be helpful to others?

1 Like

@Spencer_Matthews - yes, I think many users would benefit from it. If you want to put together a repo with a README and/or a blog post detailing the setup, you can share it in the forum here under the “Show & Tell” topic!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.