Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > Also, if you are using multiple threads to retrieve the xml source(s) > and any thread blocks due to network problems, the thread can go way by > itself after the default timeout expires. > > Typo, edited for clarity: That is: "..the thread can go *away* by itself after the default timeout

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
Anjanesh Lekshminarayanan wrote: > fp = urllib.urlopen(url) > data = fp.read() > > Retrieving XML data via an XML service API. > Very often network gets stuck in between. No errors / exceptions. > > CTRL+C > > File "get-xml.py", line 32, in > fp = urllib.urlopen(url) > File "/usr/lib/py

Re: MySQLdb

2009-11-22 Thread Gerald Walker
Kill Joy wrote: > Hi all. > > I have a mod_python script with two query: > > cursor = db.cursor() > > sql = 'SELECT * FROM users where username=\'' + username +'\'' > cursor.execute(sql) > result = cursor.fetchall() > num = int(cursor.rowcount) > > if num ==