checking invalid urls with ssl + python 2.1.3 on linux/windows

J

Josef Meile

Hi,

I'm trying to do a simple link checking for python 2.1.3 (compiled from
source on linux), but it fails when I use an invalid ssl url. For
example: I have zope without ssl running on port 8080, if I do this on
the browser's address bar:

https://my_ip:8080 --> The https is intentional

mozilla on linux and IE on windows, take a long time till a timeout
occurs. I tried to check this timeout with the timeoutsocket.py (version
1.23, the latest I could find) on linux, but it hangs:

import timeoutsocket
import smtplib
import urllib2

timeoutsocket.setDefaultSocketTimeout(5)
urllib2.urlopen('https://my_ip:8080')

Same happens with:

import httplib
import timeoutsocket
import smtplib

timeoutsocket.setDefaultSocketTimeout(5)
connection=httplib.HTTPSConnection('my_ip:8080')
connection.request('GET','/')

I searched on the newsgrous and found that timeoutsocket doesn't work
with ssl sockets. So, I tried with signal alarms and the httplib and it
succeeded on linux, but it doesn't work on windows because this os lacks
of "signal.SIGALRM" :-(. I now about "socket.setdefaulttimeout", but
this is a new feature and it doesn't exist on python 2.1.3 and I have to
provide compatibility to this version (zope 2.6.x uses it).

Finally I found a message from Geoffrey Talvola, where he said that he
has a patch which corrects this, but unfortunatelly I tried to contact
him without any success. Does any body has such patch or perhaps a
better idea of how to solve this problem?

Regards,
Josef
 
J

Josef Meile

Josef said:
>
[snip]

I searched on the newsgrous and found that timeoutsocket doesn't work
with ssl sockets. So, I tried with signal alarms and the httplib and it
succeeded on linux, but it doesn't work on windows because this os lacks
of "signal.SIGALRM" :-(. I now about "socket.setdefaulttimeout", but
this is a new feature and it doesn't exist on python 2.1.3 and I have to
provide compatibility to this version (zope 2.6.x uses it).

I gave up, I tried everything from timeoutsocket till threads, but it
always hangs. Even with threads, it doesn't matter if they are set as
daemons, the main thread will wait till the child threads are finished,
thing that doesn't happen, so it just hangs. I search several
alternatives and found that it is not a timeoutsocket problem. It seems
to be a bug on the ssl sockets of 2.1.3. So, I guess I will have to
avoid https url checking with this old python.

Regards,
Josef
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,202
Latest member
MikoOslo

Latest Threads

Top