ftplib:low download & upload speeds when using python ftplib

This is the place for queries that don't fit in any of the other categories.

ftplib:low download & upload speeds when using python ftplib

Postby dilbert_here » Fri May 31, 2013 5:04 pm

Hello All,

I was wondering if any one observed the time taken to download or upload a file over ftp using Python's ftplib is very large as compared to performing FTP get/put manually over windows command prompt or using Perl's Net::FTP module.

I created a simple FTP client similar to http://code.activestate.com/recipes/521 ... tp-client/ but I am unable to attain the speed which I get when running FTP manually on Windows DOS prompt or using perl. Is there something I am missing or is it a problem with the Python ftplib module.

I would really appreciate if you could throw some light as to why I am getting low throughput with Python.

Thanks & regards
Tanmoy
dilbert_here
 
Posts: 3
Joined: Fri May 31, 2013 4:47 pm

Re: ftplib:low download & upload speeds when using python ft

Postby hrs » Fri May 31, 2013 8:48 pm

In the comments to that code it says
hasanatkazmi wrote:in "put", you logged off and then logged in again, why? this looks like a work around for a potential bug

Here it says
In your python script make sure you reuse your initial connection.

pointing to the same thing. Are you creating a new connection for each file?

edit:
And the first comment says something about block size.
Maybe a larger block size helps.
Code: Select all
        handle.storbinary("STOR " + filename,f,1024)
hrs
 
Posts: 86
Joined: Thu Feb 07, 2013 9:26 pm

Re: ftplib:low download & upload speeds when using python ft

Postby dilbert_here » Tue Jun 04, 2013 7:11 pm

Sorry for the confusion, I had modified the above script & was using block size of 1024.

Here is the upload part of the code,

Code: Select all
def putfile(file=file, site=site, dir=dir, user=())
   upFile = open(file, 'rb') # upFile file of same name
       handle = ftplib.FTP(site) # connect to ftp site
    apply(handle.login, user) # anonymous or real login
    print "Upload started"
    handle.storbinary('STOR ' + file, upFile, 1024)
    print "Upload completed"
    handle.quit()
    upFile.close()
dilbert_here
 
Posts: 3
Joined: Fri May 31, 2013 4:47 pm

Re: ftplib:low download & upload speeds when using python ft

Postby dilbert_here » Tue Jun 04, 2013 8:58 pm

I tried to further increase the block size to 256Kb, then I am getting the throughput similar to what i get with Windows DOS.

Thanks
dilbert_here
 
Posts: 3
Joined: Fri May 31, 2013 4:47 pm


Return to General Coding Help

Who is online

Users browsing this forum: dboxall123, Google [Bot] and 3 guests