[Twisted-web] Error using getPage

Richard Townsend richard at reticulatus.plus.com
Sun Mar 12 08:44:28 CST 2006


I was testing accessing url 
"http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml" 
using getPage() which was working fine until I deliberately changed the 
url to 
"http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rssZZ.xml" 
to test error handling.

Instead of calling my errback, it gave:

Traceback (most recent call last):
  File "/usr/local/lib/python2.4/site-packages/twisted/python/log.py", 
line 53, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.4/site-packages/twisted/python/log.py", 
line 38, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File 
"/usr/local/lib/python2.4/site-packages/twisted/python/context.py", line 
59, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File 
"/usr/local/lib/python2.4/site-packages/twisted/python/context.py", line 
37, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File 
"/usr/local/lib/python2.4/site-packages/twisted/internet/selectreactor.py", 
line 139, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "/usr/local/lib/python2.4/site-packages/twisted/internet/tcp.py", 
line 349, in doRead
    return self.protocol.dataReceived(data)
  File 
"/usr/local/lib/python2.4/site-packages/twisted/protocols/basic.py", 
line 232, in dataReceived
    why = self.lineReceived(line)
  File "/usr/local/lib/python2.4/site-packages/twisted/web/http.py", 
line 341, in lineReceived
    key, val = line.split(':', 1)
exceptions.ValueError: need more than 1 value to unpack

-------------------
Code:

from twisted.internet import reactor
from twisted.web.client import getPage

def handleCallback(response):
    print 'response: %s' % response
    reactor.stop()
   
def handleErrback(failure):
    print 'error: %s' % failure.getErrorMessage()
    reactor.stop()

url = 
"http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rssZZ.xml"

deferred = getPage(url)
deferred.addCallbacks(handleCallback,
                      handleErrback)
reactor.run()
-------------------

Is there a fix for this problem ?

I am using Twisted 2.2.0/Twisted-web 0.5.0 with Python 2.4.1 on SUSE 9.3

regards,
Richard Townsend





More information about the Twisted-web mailing list