Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: ftplib throws: IndexError: tuple index out of range Date: Sun, 14 Feb 2016 19:10:16 +0100 Lines: 50 Message-ID: References: <56C05CEF.5080304@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de A08WUYTmqlEGDCnr2Daj2gWw4vKzPv8j8Gi7DCE0RNGA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'args.': 0.09; 'e.args[0]': 0.09; 'ftplib': 0.09; 'timeout': 0.09; 'tuple': 0.09; 'exception': 0.13; 'index': 0.13; '478': 0.16; 'eintr:': 0.16; 'fires': 0.16; 'frame,': 0.16; 'indexerror:': 0.16; 'innermost': 0.16; 'received :adsl-dyn.isp.belgacom.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'socket.py': 0.16; 'wrote:': 0.16; 'mechanism': 0.18; 'try:': 0.18; 'skip:" 30': 0.20; 'defined': 0.23; 'seems': 0.23; 'somewhere': 0.24; 'written': 0.24; 'header :In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'error': 0.27; 'actual': 0.28; 'looks': 0.29; 'arguments,': 0.29; 'readline': 0.29; 'received:192.168.1.3': 0.29; 'raise': 0.29; 'starts': 0.29; 'program,': 0.29; 'received:be': 0.30; 'probably': 0.31; 'skip:s 30': 0.31; 'anyone': 0.32; 'class': 0.33; 'problem': 0.33; 'raised': 0.33; 'skip:/ 20': 0.33; 'file': 0.34; 'except': 0.34; 'problem.': 0.35; 'remote': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'self': 0.38; 'data': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'charset:windows-1252': 0.62; 'backup': 0.66; 'locals': 0.84; 'pardon': 0.84; 'received:195.238': 0.84; 'schreef': 0.84 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CWAQDUwcBW/1KZhG0NUYQMbbokgWcZhXQCgVcSAQEBAQEBAYVMAQEEeBELGAkWDwkDAgECAUUTCAK0cop6hAoBAQgCAR2GEYQ1g3mBBYNuBZZ5gTuEFIgGgiaMTo4+JgGEH2mIVgEBAQ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102919 Op 14-02-16 om 14:40 schreef Peter Otten: > Antoon Pardon wrote: > >> I have written a small backup program, that uses ftplib to make >> remote backups. However recentely the program starts to regularly >> raise IndexErrors, as far as I can see the problem is in socket.py >> Can anyone shed some light? >> >> This is the traceback: > > [...] > >> File "/usr/lib/python2.7/socket.py", line 478, in readline >> if e.args[0] == EINTR: >> IndexError: tuple index out of range > > The offending line seems to be part of > > try: > data = self._sock.recv(self._rbufsize) > except error, e: > if e.args[0] == EINTR: > continue > raise > > >> Locals by frame, innermost last > > [...] > >> Frame readline in /usr/lib/python2.7/socket.py at line 478 >> buf = >> buf_len = 0 >> e = timeout() >> self = >> size = 8193 > > It looks like the actual error is socket.timeout which is probably raised > from somewhere inside the stdlib without args. I think I know what is going on. I have my own timeout mechanism at work here, that works with signals and alarm. When the SIGALRM fires I just raise the socket.timeout without arguments, which then causes the problem. I defined my own timeout exception class and now raise that and the problem disappeared. Thanks for the extra pair of eyes. -- Antoon Pardon.