Last active
September 21, 2017 10:14
-
-
Save dw/3439f9f3c9c8f275639770e93d3c1a89 to your computer and use it in GitHub Desktop.
Mitogen (local and remote loop example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import mitogen | |
def main(router): | |
u = router.ssh(hostname='u') | |
root = router.sudo(via=u, password='x') | |
for x in xrange(100): | |
root.call(subprocess.check_call, ['true']) | |
if __name__ == '__main__' and mitogen.is_master: | |
import mitogen.utils | |
mitogen.utils.run_with_router(main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import mitogen | |
def x(): | |
for x in xrange(100): | |
subprocess.check_call(['true']) | |
def main(router): | |
u = router.ssh(hostname='u') | |
root = router.sudo(via=u, password='x') | |
root.call(x) | |
if __name__ == '__main__' and mitogen.is_master: | |
import mitogen.utils | |
mitogen.utils.run_with_router(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment