Martin Panter added the comment:

Serhiy, regarding _getresp() calling resp.decode(): You are probably right that 
a failure decoding the response line is recoverable in some circumstances, such 
a GROUP command. But in other cases, say an ARTICLE command, the response won’t 
have been fully drained, so the connection is no longer usable. I guess I could 
shift the error handling to a higher level if you think it is necessary.

Regarding the workaround in my original post: It is not a good solution, 
because it is still trying to send a QUIT request and wait for a response in 
the error handler. If you are trying to interrupt a hanging network connection 
for example, you have to hit Ctrl+C twice, or wait a long time for the QUIT 
command to get some invalid data and raise its confusing protocol error.

David: The error handling inside _getlongresp() is the main place that 
concerned me. But as I made the changes there I identified the other places I 
thought could raise unexpected exceptions (network errors) or block (therefore 
a KeyboardInterrupt is likely).

Draining the response might be sensible for handling an error writing to the 
file in some cases. My /dev/full example was actually meant to be a simple 
example of more complicated exceptions, such as KeyboardInterrupt, network 
timeouts, or if the programmer wants to peek at the start of a large message 
and then abort the download. So it seems my simplified test case was 
misleading, because in these other cases, draining the response isn’t so 
appropriate.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to