Upload using python script takes very long on one laptop as compared to another

Posted by Engr Am on Stack Overflow See other posts from Stack Overflow or by Engr Am
Published on 2012-09-13T12:20:23Z Indexed on 2012/09/13 15:38 UTC
Read the original article Hit count: 247

Filed under:
|
|

I have a python 2.7 code which uses STORBINARY function for uploading files to an ftp server and RETRBINARY for downloading from this server.

However, the issue is the upload is taking a very long time on three laptops from different brands as compared to a Dell laptop. The strange part is when I manually upload any file, it takes the same time on all the systems.

The manual upload rate and upload rate with the python script is the same on the Dell Laptop. However, on every other brand of laptop (I have tried with IBM, Toshiba, Fujitsu-Siemens) the python script has a very low upload rate than the manual attempt. Also, on all these other laptops, the upload rate using the python script is the same (1Mbit/s) while the manual upload rate is approx. 8 Mbit/s.

I have tried to vary the filesize for the upload to no avail. TCP Optimizer improved the download rate on all the systems but had no effect on the upload rate. Download rate using this script on all the systems is fine and same as the manual download rate.

I have checked the server and it has more than 90% free space. The network connection is the same for all the laptops, and I try uploading only with one laptop at a time. All the laptops have almost the same system configurations, same operating system and approximately the same free drive space. If anything the Dell laptop is a little less in terms of processing power and RAM than 2 of the others, but I suppose this has no effect as I have checked many times to see how much was the CPU usage and network usage during these uploads and downloads, and I am sure that no other virus or program has been eating up my bandwidth.

Here is the code ('ftp' and 'file_path' are inputs to the function):

path,filename=os.path.split(file_path)

filesize=os.path.getsize(file_path)

deffilesize=(filesize/1024)/1024

f = open(file_path, "rb")

upstart = time.clock()

print ftp.storbinary("STOR "+filename, f)

upende = time.clock()-upstart

outname="Upload "

f.close()

return upende, deffilesize, outname

© Stack Overflow or respective owner

Related posts about python

Related posts about upload