Package: temporal-python-sdk
Unofficial Python SDK for the Temporal Workflow EngineStatusThis should be considered EXPERIMENTAL at the moment. At the moment, all I can say is that thetest casescurrently pass. I have not tested this for any real world use cases yet.Installationpip install temporal-python-sdkSample CodeSample code for using this library can be found inWorkflows in Python Using Temporal.Hello Worldimportasyncioimportloggingfromdatetimeimporttimedeltafromtemporal.activity_methodimportactivity_methodfromtemporal.workerfactoryimportWorkerFactoryfromtemporal.workflowimportworkflow_method,Workflow,WorkflowClientlogging.basicConfig(level=logging.INFO)TASK_QUEUE="HelloActivity-python-tq"NAMESPACE="default"# Activities InterfaceclassGreetingActivities:@activity_method(task_queue=TASK_QUEUE,schedule_to_close_timeout=timedelta(seconds=1000))asyncdefcompose_greeting(self,greeting:str,name:str)->str:raiseNotImplementedError# Activities ImplementationclassGreetingActivitiesImpl:asyncdefcompose_greeting(self,greeting:str,name:str):returngreeting+" "+name+"!"# Workflow InterfaceclassGreetingWorkflow:@workflow_method(task_queue=TASK_QUEUE)asyncdefget_greeting(self,name:str)->str:raiseNotImplementedError# Workflow ImplementationclassGreetingWorkflowImpl(GreetingWorkflow):def__init__(self):self.greeting_activities:GreetingActivities=Workflow.new_activity_stub(GreetingActivities)passasyncdefget_greeting(self,name):returnawaitself.greeting_activities.compose_greeting("Hello",name)asyncdefclient_main():client=WorkflowClient.new_client(namespace=NAMESPACE)factory=WorkerFactory(client,NAMESPACE)worker=factory.new_worker(TASK_QUEUE)worker.register_activities_implementation(GreetingActivitiesImpl(),"GreetingActivities")worker.register_workflow_implementation_type(GreetingWorkflowImpl)factory.start()greeting_workflow:GreetingWorkflow=client.new_workflow_stub(GreetingWorkflow)result=awaitgreeting_workflow.get_greeting("Python")print(result)print("Stopping workers.....")awaitworker.stop()print("Workers stopped......")if__name__=='__main__':asyncio.run(client_main())Roadmap1.0Workflow argument passing and return valuesActivity invocationActivity heartbeat and Activity.getHeartbeatDetails()doNotCompleteOnReturnActivityCompletionClientcompletecomplete_exceptionallyActivity get_namespace(), get_task_token() get_workflow_execution()Activity RetryActivity Failure Exceptionsworkflow_execution_timeout / workflow_run_timeout / workflow_task_timeoutWorkflow exceptionsCron workflowsWorkflow static methods:await_till()sleep()current_time_millis()now()random_uuid()new_random()get_workflow_id()get_run_id()get_version()get_logger()Activity invocation parametersQuery methodSignal methodsWorkflow start parameters - workflow_id etc...Workflow client - starting workflows synchronouslyWorkflow client - starting workflows asynchronously (WorkflowClient.start)Get workflow result after async execution (client.wait_for_close)Workflow client - invoking signalsWorkflow client - invoking queries1.1ActivityStub and Workflow.newUntypedActivityStubRemove threading, use coroutines for everything all concurrencyClasses as arguments and return values to/from activity and workflow methods (DataConverter)Type hints for DataConverterParallel activity execution (STATUS: there's a working but not finalized API).1.2TimersCustom workflow ids through start() and new_workflow_stub()WorkflowStub and WorkflowClient.newUntypedWorkflowStubContinueAsNewSticky workflowsChild Workflows1.3Support for keyword arguments2.0Compatibility with Java clientCompatibility with Golang clientUpgrade python-betterprotoPost 2.0:sideEffect/mutableSideEffectLocal activityCancellation ScopesExplicit activity ids for activity invocations