0

I am looking to improve performance of my python lamda which copies files on same sftp server for backup. This is my current code:

for attr in sftp_server.listdir_attr():
    if dt.datetime.fromtimestamp(attr.st_mtime) > date_limit:
        c = sftp_server.open(attr.filename, 'r')
        d = c.read()
        with sftp_server.open(copy_target_1 + attr.filename, 'w') as x:
            x.write(d)
        with sftp_server.open(copy_target_2 + attr.filename, 'w') as y:
            y.write(d)
        c.close()

Is there any way to increase the copy speed? Are there any libraries I can use? Thank you

Ninad Gaikwad
  • 4,272
  • 2
  • 13
  • 23
  • which python version are you using? if you are using python3.x remove python2.7 and visa versa. if you want ans work in both than remove both 3.x and 2.7 tag. only python tag will do – Nihal Aug 14 '18 at 07:42
  • Hardly. See [How can I copy/duplicate a file to another directory using SFTP?](https://stackoverflow.com/q/28089821/850848). – Martin Prikryl Aug 19 '18 at 07:16
  • That linked question has nothing to do with python. I am trying to automate my copy process using AWS lamdas. – Ninad Gaikwad Aug 20 '18 at 09:12

0 Answers0