Hi,
I use urllib to retrieve data via HTTP. Unfortunately my program crashes
after a while (after some loops) because the connection timed out.
raise socket.error, msg
IOError: [Errno socket error] (60, 'Connection timed out')
I am not so familiar with python, but is there a possibility to
configure the 'waiting time'? Or how can I handle such an event? To skip
that query and go to the next one would also work.
Many thanks in advance, Andreas
code:
params = urllib.urlencode({'rs': rs})
try:
file =
urllib.urlopen("http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?%s" %
params)
except IOError, message: # file open failed
print >> sys.stderr, "File could not be opend:", message
sys.exit(1)
data = file.readlines() # array with html-doc-content
file.close() 2 2390
Andreas,
I had a similar problem and coded in two tries; could be 3,4 etc.
I couldn't find a way to set the timeout.
Andreas Dahl wrote: Hi,
I use urllib to retrieve data via HTTP. Unfortunately my program crashes after a while (after some loops) because the connection timed out.
raise socket.error, msg IOError: [Errno socket error] (60, 'Connection timed out')
I am not so familiar with python, but is there a possibility to configure the 'waiting time'? Or how can I handle such an event? To skip that query and go to the next one would also work.
Many thanks in advance, Andreas
code: params = urllib.urlencode({'rs': rs}) try: file = urllib.urlopen("http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?%s" % params) except IOError, message: # file open failed print >> sys.stderr, "File could not be opend:", message sys.exit(1) data = file.readlines() # array with html-doc-content file.close()
Andreas,
Follow the link in Pieter's reply. It explains that the method
changes the timeout for ALL connections. You won't need to recode
in sockets. Thanks Pieter.
wes
Andreas Dahl wrote: Hi,
I use urllib to retrieve data via HTTP. Unfortunately my program crashes after a while (after some loops) because the connection timed out.
raise socket.error, msg IOError: [Errno socket error] (60, 'Connection timed out')
I am not so familiar with python, but is there a possibility to configure the 'waiting time'? Or how can I handle such an event? To skip that query and go to the next one would also work.
Many thanks in advance, Andreas
code: params = urllib.urlencode({'rs': rs}) try: file = urllib.urlopen("http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?%s" % params) except IOError, message: # file open failed print >> sys.stderr, "File could not be opend:", message sys.exit(1) data = file.readlines() # array with html-doc-content file.close() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gary Feldman |
last post by:
I think I've found a deficiency in the design of urllib related to https.
In order to complete an https connection, it appears that URLOpener and
hence FancyURLOpener require the key and cert...
|
by: C GIllespie |
last post by:
Dear All,
I'm having problems using the urllib module and was wondering if anyone
could suggest a solution. The only thing I can thing of is that I'm using at
university and my uni uses a...
|
by: Haim Ashkenazi |
last post by:
Hi
I'm writing a script that uses urllib on win98. until now I used python
2.3.x (x < 4) and it worked ok. I re-installed windows and installed
python 2.3.4 and now I get an error when trying to...
|
by: Pater Maximus |
last post by:
I am trying to implement the recipe listed at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/211886
However, I can not get to first base. When I try to run
import urllib...
|
by: JabaPyth |
last post by:
Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
>>import urllib
>>print urllib.urlopen('http://www.google.com/').read()
Traceback (most...
| |
by: Ali.Sabil |
last post by:
hello all,
I just maybe hit a bug in both urllib and urllib2, actually urllib
doesn't support proxy authentication, and if you setup the http_proxy
env var to...
|
by: rhitam30111985 |
last post by:
hi all,,, i am testing a web crawler on a site passsed as a command line argument.. it works fine until it finds a server which is down or some other error ... here is my code:
#!...
|
by: Abandoned |
last post by:
Hi..
I want to set 30 second urllib.urlretrieve timeout..
Because if urllib.urlretrieve can't connect to page wait 1-2 hour...
I download the images to my server with urlretrieve if you know the...
|
by: chrispoliquin |
last post by:
Hi,
I have a small Python script to fetch some pages from the internet.
There are a lot of pages and I am looping through them and then
downloading the page using urlretrieve() in the urllib...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |