[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib
New submission from Christopher Mahan : The python program crashes (stops responding) both from the command line and in IDLE (ver 3.0), after listing all the files in the approprate directory, both with ftp.dir() and with ftp.retrlines('LIST') (see prog listing below). I have to close the window (both window shell and IDLE). No other key combo responds. Python env (from IDLE): Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win32 Program: import ftplib ftp = ftplib.FTP('ftp.edgecastcdn.net', user='theusername', passwd='thepassword') ftp.cwd('chrismahan-675') ftp.dir() #ftp.retrlines('LIST') ftp.close() The username and password are correct. I am able to use the ftp resource with filezilla (3.1.6) with no problem. This runs on a Windows Server 2003 Standard Edition, Service Pack 2. This is also a completely clean install of Python 3.0. I installed it, then wrote this program. Python 2.5 is installed on this server and runs fine. Any questions: chris.ma...@gmail.com -- components: Extension Modules messages: 78603 nosy: chris.mahan severity: normal status: open title: retrlines('LIST') and dir hang at end of listing in ftplib type: crash versions: Python 3.0 ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Changes by Christopher Mahan : -- title: retrlines('LIST') and dir hang at end of listing in ftplib -> retrlines('LIST') and dir hang at end of listing in ftplib (python3.0) ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Update: Ran the same code with python 2.6.1 on the same computer, and that worked fine. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: the output: just before the non-responsiveness: -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg Added file: http://bugs.python.org/file12508/from_filezilla.png ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Added file screenshot of filezilla view of the folder in question. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: The list does not seem to contain non-ascii characters. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: I modified the program by adding line: ftp.set_debuglevel(2) START LISTING import ftplib ftp = ftplib.FTP('ftp.edgecastcdn.net', user='myuserid', passwd='mypassword') ftp.set_debuglevel(2) ftp.cwd('chrismahan-675') ftp.dir() #ftp.retrlines('LIST') ftp.close() END LISTING --- Running from idle 1.2.4 with python 2.5.4 gives this output: *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\r\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\r\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,234,6).\r\n' *resp* '227 Entering Passive Mode (72,21,82,190,234,6).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\r\n' *resp* '150 Opening ASCII mode data connection for file list' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg *get* '226 Transfer complete\r\n' *resp* '226 Transfer complete' Then running with idle 3.0 with python 3.0 gives the following result. *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,148,178).\n' *resp* '227 Entering Passive Mode (72,21,82,190,148,178).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\n' *resp* '150 Opening ASCII mode data connection for file list' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg Note that the last two lines are missing. >From a command prompt: C:\>c:\python30\python.exe c:\python_scripts\python3\candee_processor.py *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,219,8).\n' *resp* '227 Entering Passive Mode (72,21,82,190,219,8).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\n' *resp* '150 Opening ASCII mode data connection for file list' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg same command prompt but with python 2.5: C:\>c:\python25\python.exe c:\python_scripts\python3\candee_processor.py *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\r\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\r\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get*
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: I went into the source for Libs/ftplib.py and I noted that line 423 is: if self.debugging > 2: print('*retr*', repr(line)) so I changed the debuglevel to 3, as such: ftp.set_debuglevel(3) and I got these last 4 lines: -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg *retr* '' *get* '226 Transfer complete\r\n' *resp* '226 Transfer complete' First line, the last line of the listing. second line, the debug, showing the last line read third and fourth lines: the program actually completed and didn't hang! still digging ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: I added the following two lines and I was able to run the code. Before: line = fp.readline() if self.debugging > 2: print('*retr*', repr(line)) if not line: break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) After: line = fp.readline() if self.debugging > 2: print('*retr*', repr(line)) if not line: break if line == '': break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) As a patch: 426,427d425 < if line == '': < break What else do I need to do? ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Full output with debuglevel 3 *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,217,227).\n' *resp* '227 Entering Passive Mode (72,21,82,190,217,227).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\n' *resp* '150 Opening ASCII mode data connection for file list' *retr* '-rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3\n' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 *retr* '-rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi\n' -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi *retr* '-rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv\n' -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv *retr* '-rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv\n' -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv\n' -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg *retr* '' ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: haypo writes: >By default, the socket created to get the result of LIST has no >timeout (is blocking). So fp.readline() only returns an empty string >when the socket is closed (by the server). Even if the server closed the socket and fp.readline() returned an empty string, the prog should not hang, no? ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Per Giampaolo's suggestion, I added the timeout. Program listing and output below: -begin listing import ftplib ftp = ftplib.FTP('ftp.edgecastcdn.net', user='theusername', passwd='thepassword', timeout=2) ftp.set_debuglevel(3) ftp.cwd('chrismahan-675') ftp.dir() #ftp.retrlines('LIST') ftp.close() end listing *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,172,22).\n' *resp* '227 Entering Passive Mode (72,21,82,190,172,22).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\n' *resp* '150 Opening ASCII mode data connection for file list' *retr* '-rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3\n' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 *retr* '-rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi\n' -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi *retr* '-rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv\n' -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv *retr* '-rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv\n' -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv\n' -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg\n' -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg *retr* '' Traceback (most recent call last): File "C:\python_scripts\python3\candee_processor.py", line 6, in ftp.dir() File "c:\python30\lib\ftplib.py", line 511, in dir self.retrlines(cmd, func) File "c:\python30\lib\ftplib.py", line 433, in retrlines return self.voidresp() File "c:\python30\lib\ftplib.py", line 225, in voidresp resp = self.getresp() File "c:\python30\lib\ftplib.py", line 211, in getresp resp = self.getmultiline() File "c:\python30\lib\ftplib.py", line 197, in getmultiline line = self.getline() File "c:\python30\lib\ftplib.py", line 184, in getline line = self.file.readline() File "C:\Python30\lib\io.py", line 1813, in readline while self._read_chunk(): File "C:\Python30\lib\io.py", line 1560, in _read_chunk input_chunk = self.buffer.read1(self._CHUNK_SIZE) File "C:\Python30\lib\io.py", line 994, in read1 self._peek_unlocked(1) File "C:\Python30\lib\io.py", line 981, in _peek_unlocked current = self.raw.read(to_read) File "C:\Python30\lib\io.py", line 575, in read n = self.readinto(b) File "C:\Python30\lib\socket.py", line 214, in readinto return self._sock.recv_into(b) socket.timeout: timed out ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: When running scritp with python 2.5.4, got this error. I'll remove the "timeout=2" and run again. see below. Traceback (most recent call last): File "C:\python_scripts\python3\candee_processor.py", line 3, in ftp = ftplib.FTP('ftp.edgecastcdn.net', user='clie...@arcostream.com', passwd='1210184520', timeout=2) TypeError: __init__() got an unexpected keyword argument 'timeout' Same without the timeout argument: >>> *cmd* 'CWD chrismahan-675' *put* 'CWD chrismahan-675\r\n' *get* '250 CWD command successful\r\n' *resp* '250 CWD command successful' *cmd* 'TYPE A' *put* 'TYPE A\r\n' *get* '200 Type set to A\r\n' *resp* '200 Type set to A' *cmd* 'PASV' *put* 'PASV\r\n' *get* '227 Entering Passive Mode (72,21,82,190,228,195).\r\n' *resp* '227 Entering Passive Mode (72,21,82,190,228,195).' *cmd* 'LIST' *put* 'LIST\r\n' *get* '150 Opening ASCII mode data connection for file list\r\n' *resp* '150 Opening ASCII mode data connection for file list' *retr* '-rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3\r\n' -rwxrwxrwx 1 nobody nogroup 3905538 Dec 29 09:51 Bronski Beat - Why.mp3 *retr* '-rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi\r\n' -rwxrwxrwx 1 nobody nogroup873966 Dec 28 13:53 test9.avi *retr* '-rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv\r\n' -rwxrwxrwx 1 nobody nogroup 2512653 Dec 29 08:28 test9_lg.wmv *retr* '-rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg\r\n' -rwxrwxrwx 1 nobody nogroup 6549 Dec 29 08:28 test9_lg.wmv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv\r\n' -rwxrwxrwx 1 nobody nogroup 1788466 Dec 29 03:04 test9_med.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg\r\n' -rwxrwxrwx 1 nobody nogroup 6394 Dec 29 03:04 test9_med.flv.jpg *retr* '-rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv\r\n' -rwxrwxrwx 1 nobody nogroup 1263041 Dec 28 13:53 test9_sm.flv *retr* '-rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg\r\n' -rwxrwxrwx 1 nobody nogroup 6465 Dec 28 13:53 test9_sm.flv.jpg *retr* '' *get* '226 Transfer complete\r\n' *resp* '226 Transfer complete' >>> ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Update: I requested a test ftp account from edgecast. The tech's response was that he would file a request for it. Will update. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] retrlines('LIST') and dir hang at end of listing in ftplib (python3.0)
Christopher Mahan added the comment: Edgecast.com support created a test ftp account for the purpose of troubleshooting this issue. Please email me (chris.ma...@gmail.com) and I'll forward you the login info. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4791] ftplib.retrlines('LIST') hangs at the end of listing (SocketIO.close() doesn't close the socket)
Christopher Mahan added the comment: edgecast support said the ftp server is ProFTPD version 1.3.1. ___ Python tracker <http://bugs.python.org/issue4791> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com