ftplib throws: IndexError: tuple index out of range

Antoon Pardon antoon.pardon at rece.vub.ac.be
Sun Feb 14 13:10:16 EST 2016


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 = <cStringIO.StringO object at 0x7ff8c5d40298>
>>              buf_len = 0
>>                    e = timeout()
>>                 self = <socket._fileobject object at 0x7ff8c7b75b50>
>>                 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.




More information about the Python-list mailing list