[Python-Dev] Minor socket timeout quibble - timeout raises
socket.error
Bernard Yue
bernie@3captus.com
Tue, 25 Jun 2002 09:29:34 -0600
Skip Montanaro wrote:
>
> I just noticed in the development docs that when a timeout on a socket
> occurs, socket.error is raised. I rather liked the idea that a different
> exception was raised for timeouts (I used Tim O'Malley's timeout_socket
> module). Making a TimeoutError exception a subclass of socket.error would
> be fine so you can catch it with existing code, but I could see recovering
> differently for a timeout as opposed to other possible errors:
>
> sock.settimeout(5.0)
> try:
> data = sock.recv(8192)
> except socket.TimeoutError:
> # maybe requeue the request
> ...
> except socket.error, codes:
> # some more drastic solution is needed
> ...
>
+1 on your suggestion. Anyway, under windows, the current
implementation returns incorrect socket.error code for timeout. I am
working on the test suite as well as a fix for problem found. Once the
code is bug free maybe we can put the TimeoutError in.
I will leave it to Guido for the approval of the change. When he comes
back from his holiday.
Bernie
> Skip
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev