Paul Rubin <http://[EMAIL PROTECTED]> writes:
> Stefan Palme <[EMAIL PROTECTED]> writes: > > is there a way to modify the time a call of > > > > urllib.open(...) > > > > waits for an answer from the other side? Have a tool which > > automatically checks a list of websites for certain content. The > > tool "hangs" when one of the contacted websites behaves badly and > > "never" answers... > > Other than by using socket timeouts, at least in Un*x, you can also > use signal.alarm. You can only have one OS-provided alarm pending at > a time, so if you want multiple overlapping timeouts you have to > schedule them yourself with a single alarm. Note that neither of these is guaranteed to time out urllib.open(), though usually they will. Another way to solve the underlying problem is not to try to time out the network operation(s) at all, but to use threads or non-blocking sockets (e.g. using Twisted). John -- http://mail.python.org/mailman/listinfo/python-list