I have a program which queries an online database (Medline) for XML data. It caches all data using shelve to avoid hitting the database too many times. For some reason, I keep getting a RuntimeError: maximum recursion depth exceeded when attempting to add a certain record. This program has successfully handled over 40,000 records from Medline, but for whatever reason, this particular record (PMID: 16842422) produces this error. If I set maximum recursion depth to a larger value such as 5,000, I get a segfault.
Below is a script that should reproduce the problem I am having. Any guidance in solving this problem would greatly be appreciated. Thank you, Orest ####### START SCRIPT ####### import urllib, shelve from xml.dom import minidom baseurl = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' params = { 'db': 'pubmed', 'retmode': 'xml', 'rettype': 'medline' } badkey = '16842422' goodkey = '16842423' #or just about any other ID data = shelve.open('data.tmp', writeback=True) try: params['id'] = goodkey url = baseurl + urllib.urlencode(params) doc = minidom.parseString(urllib.urlopen(url).read()) print 'Successfully retrieved and parsed XML document with ID %s' % goodkey data[goodkey] = doc print 'Successfully shelved XML document with ID %s' % goodkey except RuntimeError: print 'Should not see this error message!' try: params['id'] = badkey url = baseurl + urllib.urlencode(params) doc = minidom.parseString(urllib.urlopen(url).read()) print 'Successfully retrieved and parsed XML document with ID %s' % badkey data[badkey] = doc #Should not get this message! print 'Successfully shelved XML document with ID %s' % badkey except RuntimeError, e: print 'Error shelving XML document with ID %s' % badkey print e ####### END SCRIPT ####### _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor