On this part of python script below, I want to use a sftp.put() in a separate thread/processus and kill it after a while, all in the same script. I don’t know how to write this using Thread or multiprocessing.
Is someone may show me a simple way to do it please?
Ubuntu 18.04, paramiko 2.6.0
[...]
raspi = paramiko.SSHClient()
raspi.set_missing_host_key_policy(paramiko.AutoAddPolicy())
raspi.connect(ip , username= "", password= "" , timeout=10)
sftp = raspi.open_sftp()
[...]
sftp.put(source, destination , callback=None, confirm=True)
raspi.close()
[...]
Update 1
Ok, so this code is working, but if I use all the arguments of the sftp.put(), he doesn't work and return a syntax error:
[...]
raspi = paramiko.SSHClient()
raspi.set_missing_host_key_policy(paramiko.AutoAddPolicy())
raspi.connect(ip , username= "", password= "" , timeout=10)
sftp = raspi.open_sftp()
[...]
th = threading.Thread(target=sftp.put, args=(source, destination))
th.start()
th.join()
raspi.close()
[...]
Don't work with (invalid syntax):
th = threading.Thread(target=sftp.put, args=(source, destination, callback=None, confirm=True))