Hello!
So, I’m using Pyzeebe to connect with my Camunda Cloud Cluster in order to start a process. When reading the docs (Client QuickStart — pyzeebe 3.0.4 documentation) and looking at the examples on Github (https://github.com/camunda-community-hub/pyzeebe/blob/6a56c799f18f048b7696a7fa80623c37013dfd4d/examples/worker.py), the author uses the await keyword, but without any complementary async function definition. The code given by the author in order to start a process is this one:
from pyzeebe import ZeebeClient, create_insecure_channel
# Create a zeebe client for camunda cloud
grpc_channel = create_camunda_cloud_channel(
client_id="<my_client_id>",
client_secret="<my_client_secret>",
cluster_id="<my_cluster_id>",
region="<region>", # Default is bru-2
)
zeebe_client = ZeebeClient(grpc_channel)
# Run a Zeebe process instance
process_instance_key = await zeebe_client.run_process(bpmn_process_id="My zeebe process", variables={})
The latter causes a SyntaxError when running the program. In order to solve that, I wrapped all of the previous code in an async function, and then called it using the asyncio.run() function, like this:
from pyzeebe import ZeebeClient, create_camunda_cloud_channel
import asyncio
async def main():
# Create a zeebe client for camunda cloud
grpc_channel = create_camunda_cloud_channel(
client_id="<my_client_id>",
client_secret="<my_client_secret>",
cluster_id="<my_cluster_id>",
region="<region>", # Default is bru-2
)
zeebe_client = ZeebeClient(grpc_channel)
# Run a Zeebe instance process
process_instance_key = await zeebe_client.run_process(
bpmn_process_id="My zeebe process", variables={}
)
asyncio.run(main())
With that, I can run the process instance without problems, but I don’t know if this is valid or a best practice, since it is not documented. I’m posting this because I want to hear your thoughts.
Thanks in advance!