asynchat - operation could not complete w/ blocking
Erik Max Francis
max at alcyone.com
Wed Mar 8 09:04:34 CET 2006
Andreas R. wrote:
> The problem I was having with push, is that is does not always send
> complete packages.
> The solution to this was to use sendall() instead, but sendall() gives
> blocking error messages.
The purpose of asynchat's push methods is to queue outgoing data and
send it when possible. When you're complaining that it does not always
send complete packages, that strongly implies to me that you're
misunderstanding how socket transmissions work.
With TCP you're guaranteed that data will show up in the same order you
sent it. You're not at all guaranteed that it will show up in the same
chunks, or that you will get it all at the same time.
The only time you'd want to do use something like "sendall" is when you
really _do_ want to block until you make sure all the data is sent. So
if you're wondering why it blocks, that suggests a deep misunderstanding
in how TCP works.
If you want to use asynchat to transmit data, all you need to do is set
things up so that push handles them. Once that's the case, the data
will be transmitted when the socket is writable such that it doesn't
block. In other words, all you want to do is call
push/push_with_producer and leave it at that.
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Eppur, si muove! [But still it moves!]
-- Galileo Galilei
More information about the Python-list