How to catch socket timeout?

Achim Domma domma at procoders.net
Mon Sep 22 08:38:57 EDT 2003


"Bob Halley" <halley at play-bow.org> wrote in message
news:mailman.1064178330.17024.python-list at python.org...
> So, all you need to do is put the socket.timeout except clause before
> any socket.error clause:
>
> try:
>     self.data = self.page.read()
> except socket.timeout: ...
>         except socket.error,e: ...

Thanks, that works fine, but I don't understand why the exception was not
catched in my case. If I write it like this

try:
    self.data = self.page.read()
except socket.error,e: ...
except socket.timeout: ...

the exception should be catched by the socket.error handler. Or am I wrong?
In my case it was not catched at all. Very mysterious from my point of view,
but it works now.

Achim






More information about the Python-list mailing list