Skip to main content

Compatible with: Camunda Platform 8

Coverage Status Test pyzeebe Integration test pyzeebe

GitHub tag (latest by date) PyPI PyPI - Python Version

Pyzeebe

pyzeebe is a python grpc client for Zeebe.

Zeebe version support:

Pyzeebe version Tested Zeebe versions
4.x.x 8.5, 8.6, 8.7, 8.8
3.x.x 1.0.0
2.x.x 0.23, 0.24, 0.25, 0.26
1.x.x 0.23, 0.24

Getting Started

To install:

pip install pyzeebe

For full documentation please visit: https://camunda-community-hub.github.io/pyzeebe/

Usage

Worker

The ZeebeWorker class gets jobs from the gateway and runs them.

import asyncio

from pyzeebe import ZeebeWorker, Job, JobController, create_insecure_channel


channel = create_insecure_channel(grpc_address="localhost:26500") # Create grpc channel
worker = ZeebeWorker(channel) # Create a zeebe worker


async def on_error(exception: Exception, job: Job, job_controller: JobController):
    """
    on_error will be called when the task fails
    """
    print(exception)
    await job_controller.set_error_status(job, f"Failed to handle job {job}. Error: {str(exception)}")


@worker.task(task_type="example", exception_handler=on_error)
def example_task(input: str) -> dict:
    return {"output": f"Hello world, {input}!"}


@worker.task(task_type="example2", exception_handler=on_error)
async def another_example_task(name: str) -> dict: # Tasks can also be async
    return {"output": f"Hello world, {name} from async task!"}

loop = asyncio.get_running_loop()
loop.run_until_complete(worker.work()) # Now every time that a task with type `example` or `example2` is called, the corresponding function will be called

Stop a worker:

await zeebe_worker.stop() # Stops worker after all running jobs have been completed

Client

from pyzeebe import ZeebeClient, create_insecure_channel

# Create a zeebe client
channel = create_insecure_channel(grpc_address="localhost:26500")
zeebe_client = ZeebeClient(channel)

# Run a Zeebe process instance
process_instance_key = await zeebe_client.run_process(bpmn_process_id="My zeebe process", variables={})

# Run a process and receive the result
process_instance_key, process_result = await zeebe_client.run_process_with_result(
    bpmn_process_id="My zeebe process",
    timeout=10000
)

# Deploy a BPMN process definition
await zeebe_client.deploy_resource("process.bpmn")

# Cancel a running process
await zeebe_client.cancel_process_instance(process_instance_key=12345)

# Publish message
await zeebe_client.publish_message(name="message_name", correlation_key="some_id")

Tests

Use the package manager pip to install pyzeebe

pytest tests/unit

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

We use the MIT license, see LICENSE.md for details

Release files for pyzeebe 4.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyzeebe 4.7.0
File Size Uploaded
pyzeebe-4.7.0.tar.gz 169.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyzeebe 4.7.0
File Interpreter ABI Platform
pyzeebe-4.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 240.4 kB

Release files / pyzeebe-4.7.0.tar.gz

Download URL pyzeebe-4.7.0.tar.gz
Size 169.5 kB
Tags Source
SHA-256 checksum
How to use checksums
767b94f28fbd2a6a6fba13351d7febab87c8539968355f786c581f4513d4bd93
BLAKE2b-256 checksum
How to use checksums
3a9e40ea3fcd0839dff1f90387643b2fcd062edaa487dd1cb7ed09bd33d8fa1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release files / pyzeebe-4.7.0-py3-none-any.whl

Download URL pyzeebe-4.7.0-py3-none-any.whl
Size 70.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e814e248da8d266ef78846eb3d57827de95a4df388401eacd791269aa844803
BLAKE2b-256 checksum
How to use checksums
f9e57363f70da113b518e3bda9006405a037256c329eff5b7c037068e7835d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release history Release notifications | RSS feed

This release

4.7.0 This release

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.4.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page