Skip to content

Instantly share code, notes, and snippets.

@dw
Last active September 21, 2017 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dw/3439f9f3c9c8f275639770e93d3c1a89 to your computer and use it in GitHub Desktop.
Save dw/3439f9f3c9c8f275639770e93d3c1a89 to your computer and use it in GitHub Desktop.
Mitogen (local and remote loop example)
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)
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