python异步执行命令_Python远程链接服务器启动执行命令,Python异步操作,python

# import paramiko as paramiko

# import time

# ssh = paramiko.SSHClient()

# ssh.load_system_host_keys()

# ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# ssh.connect(hostname='xxx.xxx.xxx.xxx', port=22, username='hamzsy', password='123456',compress=True)

# # stdin, stdout, stderr = ssh.exec_command('bash --login -c "appium"')

# stdin, stdout, stderr = ssh.exec_command('lsof -i:4723')

# # time.sleep(3)

# # stdin, stdout, stderr = ssh.exec_command('pwd')

# # ssh.exec_command('kill -9 4091')

# print(stdout.read().decode().split(' ')[12].split(' ')[0])

# # ssh.exec_command('kill -9 3874')

# # print(stdout.read().decode())

#

# ssh.close()

from threading import Thread

from time import sleep

def asynca(f):

def wrapper(*args, **kwargs):

thr = Thread(target=f, args=args, kwargs=kwargs)

thr.start()

return wrapper

@asynca

def A():

sleep(5)

print("a function")

def B():

print("b function")

A()

B()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值