473,714 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ftplib.FTP.retr binary() hangs on completion

aum
Hi,

I've been having some headaches with FTP.retrbinary( ) hanging on
completion.

I'm only seeing the symptom when downloading a 700k .bmp file in passive
mode.

What happens is that after all the data comes in over the data connection,
..retrbinary() does 'return self.voidresp() '. This has a call chain ending
with 'self.file.read line()'.

To investigate, I overrode the .getline() method with one
which replaces the self.file.readl ine() with a self.sock.recv( 1) loop, and
determined from this that after the last byte of binary data comes in on
the data connection, not a single byte comes in on the control connection.

Not sure if this is a deeper underlying socket issue - I'm running
python2.3 on debian unstable linux.

For a workaround, I've overridden retrbinary, so that it sets a socket
timeout on the control connection prior to doing the last .voidresp()
call, and in the event of timeout, it closes the control connection,
reconnects and logs in again - very ugly.

Can anyone share some light, or offer a better workaround?

--

Cheers
aum
Jun 29 '06 #1
1 6095
"aum" <au*@spam.me.pl ease> wrote:
What happens is that after all the data comes in over the data connection,
.retrbinary() does 'return self.voidresp() '. This has a call chain ending
with 'self.file.read line()'.

To investigate, I overrode the .getline() method with one
which replaces the self.file.readl ine() with a self.sock.recv( 1) loop, and
determined from this that after the last byte of binary data comes in on
the data connection, not a single byte comes in on the control connection.


since both sides has closed the data connection socket when you get that far, it
looks like the server you're talking to is broken; see

http://cr.yp.to/ftp/retr.html

for details on what the server is supposed to do, and what the client can expect
from the server.

</F>

Jun 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7833
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at a time and providing status updates via a GUI interface. Finally, I close the socket, set it to...
2
2259
by: siggy2 | last post by:
Hi, I'm using Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 I've noticed a strange (= not deterministic) behaviour of ftplib.py: sometimes (not always) it fails (after a variable number of minutes from 15 to 130) downloading a 150 MB BINARY file (a big gzipped ascii file) with the traceback reported below. IMVHO this is not a timeout error because my script import
1
2497
by: Robert | last post by:
I just tried to convert a (hugh size) ftp.retrbinary run into a pseudo-file object with .read(bytes) method in order to not consume 500MB on a copy operation. First I thought, its easy as usual with python using something like 'yield' or so. Yet I didn't manage to do (without using threads or rewriting 'retrbinary')? Any ideas?
5
6911
by: Richard Lewis | last post by:
Hi there, I'm having a problem with unicode files and ftplib (using Python 2.3.5). I've got this code: xml_source = codecs.open("foo.xml", 'w+b', "utf8") #xml_source = file("foo.xml", 'w+b') ftp.retrbinary("RETR foo.xml", xml_source.write)
2
9573
by: Harlin Seritt | last post by:
Using ftplib from Python I am trying to get all files in a particular directory using ftplib and then send those same files to another ftp server. I have tried using commands like 'get *' and 'mget *' with no success. I am using the following: srcFtp = FTP(srcHost) srcFtp.login(srcUser, srcPass) srcDir = srcFtp.nlst('.')
0
1981
by: Michal Seidl | last post by:
Hi, I am trying to download data from remote ftp server connected through GSM modem. The speed is slow 1kB/s. Despite the classic linux ftp client works fine the ftp.retrbinary(),ftpretrlines() function from ftplib hangs. I am able succesfuly login but a can not download. It has probably something common with sockets. Code: *************************************** #Open ftp connection and downloads file
0
1336
by: jeff.dyke | last post by:
I am using ftplib in some code that does exactly what you would expect. It ftp's files. Its running inside a service running on windows xp and windows 2003 servers, approximately 20 installations each installation sends between 100 and 1000 files per day. Occasionally the process will hang completely and the only way to restart the service is to kill the pythonservice.exe (via End Process in Task Manager) service and start it. I have...
3
3701
by: alex | last post by:
Hello, My script is trying to get a file from a remote server, every day it ftps from a directory. My code works perfect if I know the name of the file in the remote directory. ftp.retrbinary('RETR ' + filename, handleDownload) The problem is that in the future the name of the file is going to be aleatory. How can I get the file's name (only one file is in that
2
7197
by: fepeacock | last post by:
I am breaking/interrupting my connection with the ftp server at present when doing a partial download of a file. I have a callback with retrbinary that raises an exception and ends the download. The problem is that the server is not notified and hangs. I cannot send any further commands and need to relogin to download further. Is there a way to still continue downloading without having to login again. My retrbinary function is: ...
0
8808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8712
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9316
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9077
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3159
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2524
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.