Skip to content

Event when one remote command has finished #296

Answered by pkittenis
f380cedric asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

Thanks for the interest. Short answer is no. Callback support is tracked by #275.

It could be done client side by spawning callback greenlets on top of SSHClient.wait_finished. Eg, something like:

from gevent import spawn


def my_cb(host_out):
    try:
        host_out.client.wait_finished()
    except Exception as ex:
        exc = ex
    else:
        exc = None
    print(f"Command on host {host_out.host} exited with error code {host_out.exit_code}, exception {exc}")


output = client.run_command(<..>)
callbacks = [spawn(my_cb, host_out) for host_out in output]

Can similarly do something other than print in the callback.

wait_finished will block the current greenlet. Anything afte…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pkittenis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants