xmlrpclib hangs execution

Arno Stienen arnoreg at gmail.com
Tue Jul 10 05:10:56 EDT 2007


Hi Andy,

Your patches solves the problem too. Thanks!

One thing: if I use the unpatched xmlrpclib.py, the printed output of 
xml calls look like:

	{'state': 0, 'str': 'Info_RT'}

But if I use your patch, they look like:

	state0strInfo_RT

I prefer the former, as it is easier to extract the info. Why did this 
change with your patch?

Bye,
Arno.



itkovian wrote:
> I think a better fix than the one I posted below is using the
> HTTPConnection library, as opposed to the HTTP library from httplib.
> 
> A patch can be found below:
> 
> --- /sw/lib/python2.5/xmlrpclib.py      2006-11-29 02:46:38.000000000
> +0100
> +++ xmlrpclib.py        2007-06-15 16:03:17.000000000 +0200
> @@ -1182,23 +1182,13 @@
>          self.send_user_agent(h)
>          self.send_content(h, request_body)
> 
> -        errcode, errmsg, headers = h.getreply()
> +        response = h.getresponse()
> +
> +        if response.status != 200:
> +          raise ProtocolError(host + handler, response.status,
> response.reason, response.msg.headers)
> 
> -        if errcode != 200:
> -            raise ProtocolError(
> -                host + handler,
> -                errcode, errmsg,
> -                headers
> -                )
> -
> -        self.verbose = verbose
> -
> -        try:
> -            sock = h._conn.sock
> -        except AttributeError:
> -            sock = None
> -
> -        return self._parse_response(h.getfile(), sock)
> +        payload = response.read()
> +        return payload
> 
>      ##
>      # Create parser.
> @@ -1250,7 +1240,7 @@
>          # create a HTTP connection object from a host descriptor
>          import httplib
>          host, extra_headers, x509 = self.get_host_info(host)
> -        return httplib.HTTP(host)
> +        return httplib.HTTPConnection(host)
> 



More information about the Python-list mailing list