Created
September 22, 2023 01:03
-
-
Save simryang/401ccbacc9764edb05d3bfd0e955c155 to your computer and use it in GitHub Desktop.
example for how to do remote ssh command via asyncssh/asyncio
This file contains 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 time | |
import asyncssh | |
import asyncio | |
params = range(10) | |
async def run(): | |
async with asyncssh.connect("localhost", 8090, username="tester", password="t35t3r", known_hosts=None) as conn: | |
for param in params: | |
await conn.create_process(f"nohup very_very_long_run.sh {param} &") | |
async def main(loop): | |
await asyncio.sleep(0) | |
t1 = loop.create_task(run()) | |
await t1 | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main(loop)) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment