This is still happening in 12.04. The problem is that the reason variable coming from an IOError is an (errno, strerror) tuple, so
reasonstr = "\nReason: %s" % reason if reason is not None else ""
raises a TypeError. You could change this to
reasonstr = "\nReason: %s" % str(reason)
For reason == None, this would result in "Reason: None", which I think is better than "".
For reason == (123, 'Some error'), it would result in "Reason: (123, 'Some error')" instead of crashing.
Of course, the IOError itself should be avoided by some delay, as well, as heynnema suggested, but this patch would at least avoid the crash.
This is still happening in 12.04. The problem is that the reason variable coming from an IOError is an (errno, strerror) tuple, so
reasonstr = "\nReason: %s" % reason if reason is not None else ""
raises a TypeError. You could change this to
reasonstr = "\nReason: %s" % str(reason)
For reason == None, this would result in "Reason: None", which I think is better than "".
For reason == (123, 'Some error'), it would result in "Reason: (123, 'Some error')" instead of crashing.
Of course, the IOError itself should be avoided by some delay, as well, as heynnema suggested, but this patch would at least avoid the crash.