Determine size of string in bytes
hacker.stevenson at gmail.com
Thu Mar 27 22:46:01 CET 2008
On Mar 27, 2:10 pm, John Machin <sjmac... at lexicon.net> wrote:
> On Mar 28, 6:45 am, breal <hacker.steven... at gmail.com> wrote:
> > Forgive me for this question which is most likely stupid...
> The contents of your question are not stupid. The subject however does
> invite a stupid answer like: len(the_string).
> Disclaimer: I know nothing about SOAP except that it's usually
> capitalised :-) Now read on:
> > How do I determine the number of bytes a string takes up? I have a
> > soap server that is returning a serialized string.
> Serialised how? UTF-8?
Yes. I meant to include that. I did not understand that len()
returned the actual byte length of a UTF-8 encoded string.
> > It seems that when
> > the string goes over 65978 characters it does not return to the soap
> > client.
> Why does it seem so? How did you arrive at such a precise limit?
I actually just wrote a test that would call a function on the SOAP
server (SOAPpy) that would increase or decrease the test length based
on the previous result until it found x, x+1 where x characters didn't
fail, but x+1 did. x ended up being 65978. The string I happen to be
encoding in this case has all ascii characters so it is the same for
> > Instead I get an error:
> > error: (35, 'Resource temporarily unavailable')
> Is this error from the client or the server? Any error or logfile
> record from the other side?
This is an error on the server. The client is actually written in
There is no log file, but there is a traceback...
Traceback (most recent call last):
python2.5/SocketServer.py", line 464, in process_request_thread
python2.5/SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
python2.5/SocketServer.py", line 522, in __init__
python2.5/BaseHTTPServer.py", line 316, in handle
python2.5/BaseHTTPServer.py", line 310, in handle_one_request
python2.5/site-packages/SOAPpy/Server.py", line 545, in do_POST
python2.5/socket.py", line 262, in write
python2.5/socket.py", line 249, in flush
error: (35, 'Resource temporarily unavailable')
> Is there anything in the documentation about maximum sizes?
I googled my brains out looking for anything about maximum size both
on the Python SOAP server, and the PHP SOAP client.
> > This makes me think the problem exists on the soap client side with
> > some sort of max return length.
> Think? Can't you verify this by inspecting the source?
I haven't inspected the source, but I have inspected the
documentation. No luck in finding anything about it. I suppose I
could download the client source and see what I can see.
> > If I knew how many bytes the 65978
> > character string was, then I could try to up this value.
> How do you know the string is 65978 characters? If you are debugging
> the server, can't you do len(serialise(the_65978_char_string))?
> 65978? Are you sure? Looks suspiciously close to 65535 aka 0xFFFF aka
> (2 ** 16 - 1 ) to me.
> If you have the server, you presumably have the source code for both
> client and server. Some options for you:
> (1) Look at the traceback(s), look at the source code, nut it out for
> yourself. If there is some kind of max other than an implicit 16-bit
> limitation in the client code, it shouldn't be too hard to find.
> (2) Post the traceback(s) here, along with other details that might be
> useful, like what SOAP server s/w you are using, what version of
> Python, what platform.
See traceback above.
Thanks for the response John.
More information about the Python-list