基于Asyncssh和Asyncio库实现SCP传输文件

为了提升SCP并发传输速度引入异步操作

import asyncssh
import asyncio
import nest_asyncio

#引入nest_asyncio库apply()方法是为了能在jupyter上运行
nest_asyncio.apply()

async def scp_example():
    async with asyncssh.connect('host', username='username', password='pwd') as conn:
        await asyncssh.scp('/from_file', (conn, '/to_path'))

## Run the async function
asyncio.run(scp_example())
posted @ 2024-12-30 12:36  Ishuai  阅读(122)  评论(0)    收藏  举报