python2.7芹菜(等待命令,检索输出)
首先,我不知道最终获得我想要归档的功能的最佳方式是什么 我的代码将执行以下操作:python2.7芹菜(等待命令,检索输出),python,python-2.7,celery,celery-task,Python,Python 2.7,Celery,Celery Task,首先,我不知道最终获得我想要归档的功能的最佳方式是什么 我的代码将执行以下操作: @celery.task def updateServerByID(sevrerID): #run update task os.system("samplecommadn to update server by id...") #check if the output of the console contains "Success!", if yes, end job by usin
@celery.task
def updateServerByID(sevrerID):
#run update task
os.system("samplecommadn to update server by id...")
#check if the output of the console contains "Success!", if yes, end job by using "return" statement
#return
以下是我认为让代码运行的两种方法:
总之,我认为方式2是最有效的,但是如何用python读取整个控制台输出?有没有办法阻止芹菜任务本身打印此内容?这与芹菜无关,问题在于如何获取操作系统的get output的输出
只需在[python如何在运行os系统后获取stdout]()之后的
Cellery.task.updateServerByID中获取输出即可。首先,谢谢,但使用此代码,python不会等到命令以某种方式完成后再获取输出。。。