Alarms in threads - how to get/mimic?
Aahz Maruch
aahz at panix.com
Sun Dec 17 09:45:36 EST 2000
In article <Pine.LNX.4.21.0012161749380.7913-100000 at traal.eecs.berkeley.edu>,
Luca de Alfaro <dealfaro at eecs.berkeley.edu> wrote:
>
>What is not clear to me is the following. When there is a timeout,
>the exception Timeout is not caught by httplib. Hence, if the thread
>that called httplib just continues its job giving up on the
>connection, httplib will not have a chance to do any clean-up, such as
>for example releasing/closing the socket.
>
>Hence, it seems to me that in order to abort a web page load cleanly
>upon timeout, I also have to modify the httplib module to handle the
>exception Timeout, and do clean-up work if that happens.
It depends what you mean by "cleanly". You don't need to worry about
the loose socket taking up memory, generally speaking; objects clean
themselves up when they go out of scope (Python's exception model does
scope-based cleanup (unlike C++'s, if I understand C++ correctly). In
addition, if you're using httplib directly (instead of urllib), it's
fairly easy to go poking around in the internals of HTTP() if you take a
reference to it in your code before trying to do a retrieval (the object
won't go out out of scope as long as there's a reference to it).
--
--- Aahz (Copyright 2000 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"Using LOCs as a measure of programmer productivity is like estimating the
productivity of a welder by the amount of acetylene used."
More information about the Python-list
mailing list