Cyril <c...@excellency.fr> added the comment:

> Hmm, indeed. What you can do, very simply, is cache the getvalue()
> result once you have generated it.

After some thoughts, it's not really an option: my cStringIO.StringIO buffer 
is, well a buffer. To append data to the buffer, I call buffer.write(). When 
I've got a chance to send data over the socket (remember, it's async, so I 
don't really know when it's going to happen), I call buffer.getvalue().

If socket.write() returns zero byte written, I'll have to wait until I get 
another chance to send my buffer. But in the meantime, some more data might get 
appended to the buffer, and the string returned by getvalue() will be different 
from the first call (and thus, I can't really cache it).

I could find some tricks (like using multiple buffers), but it would be ugly.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8240>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to