aschmidt@fredericksburg.com wrote:
Samir Mishra <SamirMishra@cbuae.gov.ae> wrote ..
import urllib
URLsite = "http://username:password@zserver:8080/everything/else/on/path"
usock = urllib.urlopen(URLsite) data = usock.read() usock.close()
Someone else please correct me if I am wrong but we decided not to use something similar because if for some reason the site you are trying to urlopen is down, etc. then it never really times out...just sits and spins and locks that zope thread. Do that a few times and your whole site is down.
Not sure if a try: would work here but that might be worth a shot. But I guess if the urlopen never comes back then the try: would just try forever.
Am I right here or is there a better way to handle this?
Allen
There is a module available called timeoutsocket.py which enables timeouts for all TCP connections. Last time I checked, the site was down: http://www.timo-tasi.org/python/timeoutsocket.py, but the script was available by going through archive.org. I believe the module has been included in python 2.3 as part of the standard distribution.