Python客户端司机

pyconductor的Python项目详细描述


导体的python客户端

python client for conductor提供两组函数:

  1. 工作流管理API(启动、终止、获取工作流状态等)
  2. 工人执行框架

NOTE: This repository has been forked from Netflix:conductor's client/python folder. Apart from the results of renaming the module from conductor to pyconductor, (as pip already contains a conductor module), there are no code changes. This repository is mostly meant to act as an easy way to install the python client for Netflix:conductor. There are also attempts made to add documentation to the client overall. As far as possible, the library will be kept in sync with the upstream branch.

安装

pip install pyconductor

使用工作流管理API

python类WorkflowClient向指挥服务器提供客户端api调用,以开始管理工作流。

示例

importsysfrompyconductorimportconductorimportjsondefgetStatus(workflowId):workflowClient=conductor.WorkflowClient('http://localhost:8080/api')workflow_json=workflowClient.getWorkflow(workflowId)printjson.dumps(workflow_json,indent=True,separators=(',',': '))returnworkflow_json

任务工作线程执行

任务工作线程执行api使用python客户机促进任务工作线程的执行。 api提供了必要的机制,可以定期轮询任务工作,并在单独的线程中执行python工作线程。

示例

下面的python脚本演示kitchensink工作流的工作人员。

frompyconductor.ConductorWorkerimportConductorWorkerdefexecute(task):return{'status':'COMPLETED','output':{'mod':5,'taskToExecute':'task_1','oddEven':0},'logs':['one','two']}defexecute4(task):forkTasks=[{"name":"task_1","taskReferenceName":"task_1_1","type":"SIMPLE"},{"name":"sub_workflow_4","taskReferenceName":"wf_dyn","type":"SUB_WORKFLOW","subWorkflowParam":{"name":"sub_flow_1"}}];input={'task_1_1':{},'wf_dyn':{}}return{'status':'COMPLETED','output':{'mod':5,'taskToExecute':'task_1','oddEven':0,'dynamicTasks':forkTasks,'inputs':input}}defmain():print'Hello World'cc=ConductorWorker('http://localhost:8080/api',1,0.1)forxinrange(1,30):if(x==4):cc.start('task_{0}'.format(x),execute4,False)else:cc.start('task_{0}'.format(x),execute,False)cc.start('task_30',execute,True)if__name__=='__main__':main()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Clojure关键字在内存中的大小是多少?   Java中有固定长度的通用数组对象吗?   PostgreSQL:通过Java更新我的用户表   错误:使用java解析xml   java Json显示列表中对象的名称   java比较JodaTime时区   与JAVA中的API和包的区别?   java的int值在for循环中不改变   谷歌应用引擎中的java RSA   迁移到spring 5后出现java非法字符错误   java Websphere管理控制台不工作   JavaGSON如何始终在json中包含毫秒?   带有空格和双引号的windows Java ProcessBuilder命令参数失败   java错误:重复的zip条目[43.jar:org/apache/http/annotation/NotThreadSafe.class]