1
마스터에서 salt-api를 사용하여 동시에 여러 소금 명령을 실행해야합니다. 출력을 비동기식으로 가져 오려고 할 때 문제가 발생합니다.소금 - cmd_async 출력을 비동기로 가져 오는 방법
의 난 (그냥 예를 위해서) 주자에 (더 사이비 같은) 다음 코드가 있다고 가정 해 봅시다 : GitHub의 (salt/client/init.py)에, 당신은 몇 가지를 찾을 수
client = salt.client.LocalClient()
for fun in funs:
jid = client.cmd_async(target, fun, [arg])
jobs.append(jid)
out = {}
while len(jobs):
for jid in jobs:
# this can be any function that can in some way assure me about the state
# whether the command it's still running or it finished the job
state = get_salt_cmd_state(jid)
# checking if that command is really finished
# in order to get it's output
if state == FINISHED:
out[jid] = get_salt_cmd_output(jid)
jobs.remove(jid)
소금으로 찾고 이것을하기위한 방법들, 그러나 그들 대부분은 적어도 부분적으로는 블로킹을하고 있으며, 하인들의리스트를 인자로 요구한다.
이 방법을 만드는 좋은 방법이 있습니까?
팁 주셔서 감사합니다. 나는 그것을 조사 할 것이다. 그 방법에 대해 우려하는 부분은 다음과 같습니다. fn_ ret가없는 경우 : try : ret_data = self.serial.load (salt.utils.fopen (retp, 'r')) ... – Mihai