Skip to main content

Python framework for Cadence Workflow Service

Project description

Python framework for Cadence Workflow Service

Cadence is a workflow engine developed at Uber Engineering. With this framework, workflows and activities managed by Cadence can be implemented in Python code.

Status / TODO

cadence-python is still under going heavy development. It should be considered EXPERIMENTAL at the moment. A production version is targeted to be released in September of 2019 January 2020.

  • [x] Tchannel implementation
  • [x] Python-friendly wrapper around Cadence's Thrift API
  • [x] Author activities in Python
  • [x] Start workflows (synchronously)
  • [x] Create workflows
  • [x] Workflow execution in coroutines
  • [x] Invoke activities from workflows
  • [ ] Activity heartbeating and doNotCompleteOnReturn
  • [ ] Activity retry
  • [x] Signals
  • [ ] Queries
  • [x] Async workflow execution
  • [x] await
  • [x] now (currentTimeMillis)
  • [ ] Timers
  • [x] Sleep
  • [ ] Loggers
  • [x] newRandom
  • [x] UUID
  • [ ] Workflow Versioning


  • [ ] Sticky workflows

Post 2.0:

  • [ ] sideEffect/mutableSideEffect
  • [ ] Parallel activity execution
  • [ ] Cancellation Scopes
  • [ ] Child Workflows


pip install cadence-client

Hello World Sample

import sys
import logging
from cadence.activity_method import activity_method
from cadence.workerfactory import WorkerFactory
from cadence.workflow import workflow_method, Workflow, WorkflowClient


TASK_LIST = "HelloActivity-python-tasklist"
DOMAIN = "sample"

# Activities Interface
class GreetingActivities:
    @activity_method(task_list=TASK_LIST, schedule_to_close_timeout_seconds=2)
    def compose_greeting(self, greeting: str, name: str) -> str:
        raise NotImplementedError

# Activities Implementation
class GreetingActivitiesImpl:
    def compose_greeting(self, greeting: str, name: str):
        return greeting + " " + name + "!"

# Workflow Interface
class GreetingWorkflow:
    @workflow_method(execution_start_to_close_timeout_seconds=10, task_list=TASK_LIST)
    async def get_greeting(self, name: str) -> str:
        raise NotImplementedError

# Workflow Implementation
class GreetingWorkflowImpl(GreetingWorkflow):

    def __init__(self):
        self.greeting_activities: GreetingActivities = Workflow.new_activity_stub(GreetingActivities)

    async def get_greeting(self, name):
        return await self.greeting_activities.compose_greeting("Hello", name)

if __name__ == '__main__':
    factory = WorkerFactory("localhost", 7933, DOMAIN)
    worker = factory.new_worker(TASK_LIST)
    worker.register_activities_implementation(GreetingActivitiesImpl(), "GreetingActivities")

    client = WorkflowClient.new_client(domain=DOMAIN)
    greeting_workflow: GreetingWorkflow = client.new_workflow_stub(GreetingWorkflow)
    result = greeting_workflow.get_greeting("Python")

    print("Stopping workers....")
    print("Workers stopped...")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cadence-client, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size cadence_client-0.0.4-py3-none-any.whl (50.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cadence-client-0.0.4.tar.gz (43.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page