473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

asynchat - operation could not complete w/ blocking

Hi again,

I'm using Python's asynchat module for networking.
When calling the sendall() method of asynchat,
I sometimes get the error message "the operation
could not complete without blocking".

So how do I enable blocking with synchat, or otherwise fix this error?

Thanks for the help I've received with asynchat so far in this news group.

- Andreas
Mar 7 '06 #1
8 2586
"Andreas R." wrote:
I'm using Python's asynchat module for networking.
When calling the sendall() method of asynchat,
I sometimes get the error message "the operation
could not complete without blocking".


what sendall method ? to get proper output buffering with asynchat, use
"push" (or "push_with_producer").

</F>

Mar 8 '06 #2
Fredrik Lundh wrote:
"Andreas R." wrote:
I'm using Python's asynchat module for networking.
When calling the sendall() method of asynchat,
I sometimes get the error message "the operation
could not complete without blocking".


what sendall method ? to get proper output buffering with asynchat, use


Search for sendall here:
http://svn.gna.org/viewcvs/openrts/t...67&view=markup

That's what I was told to use here:
http://groups.google.no/group/comp.l...30540bd8ec9db5

That's not correct? You can try the version using sendall here:
http://svn.gna.org/daily/openrts-snapshot.tar.gz

-Andreas
www.openrts.org
Mar 8 '06 #3
Fredrik Lundh wrote:
"Andreas R." wrote:
I'm using Python's asynchat module for networking.
When calling the sendall() method of asynchat,
I sometimes get the error message "the operation
could not complete without blocking".


what sendall method ? to get proper output buffering with asynchat, use
"push" (or "push_with_producer").


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.

- Andreas
Mar 8 '06 #4
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 && ma*@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
Mar 8 '06 #5
Dennis Lee Bieber wrote:
On Wed, 08 Mar 2006 08:57:53 +0100, "Andreas R."
<an*****@nospam.openrts.org> declaimed the following in
comp.lang.python:

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.

Somehow, the above seems logical... "push" probably doesn't "send
complete packages" because doing so would require blocking; instead it
sends what won't block, presuming "you" (the programmer) will code
whatever is needed to handle partial sends and put the rest out on a
later "push".

"sendall" may be sending everything, but it does so by blocking
until the other end acknowledges enough packets have been received to
ensure that no data is lost.


Yes, this is how I understood sendall. But why does it sometimes report
the error: (10035, 'The socket operation could not complete without
blocking')
- Andreas
Mar 8 '06 #6
(possible duplicate; reposted due to mail server problems)

"Andreas R." `wrote:
what sendall method ? to get proper output buffering with asynchat, use


Search for sendall here:
http://svn.gna.org/viewcvs/openrts/t...67&view=markup

That's what I was told to use here:
http://groups.google.no/group/comp.l...30540bd8ec9db5

That's not correct?


nope. asyncore uses it's own send implementation, and asynchat implements
proper buffering on top of asyncore's send via the push methods.

the reason that you could call sendall appears to be that asyncore gives you
access to *all* socket object attributes via dynamic inheritance, and nobody
thought of filtering out the sendall method (which is a rather recent addition
to the socket layer). this should probably be fixed.

</F>

Mar 8 '06 #7
"Andreas R." wrote:
I'm using Python's asynchat module for networking.
When calling the sendall() method of asynchat,
I sometimes get the error message "the operation
could not complete without blocking".

what sendall method ? to get proper output buffering with asynchat, use "push" (or "push_with_producer").
The problem I was having with push, is that is does not always send
complete packages.


that sounds like a bug on the receiving side. the network layer is free
to split things up however it likes, and it's up to your code to put things
together again properly.
The solution to this was to use sendall() instead, but sendall() gives
blocking error messages.


sendall is blocking per definition (and it doesn't send complete packages
either; it just loops until it has managed to hand everything over to the net-
work layer).

</F>

Mar 8 '06 #8
"Andreas R." wrote:

"sendall" may be sending everything, but it does so by blocking
until the other end acknowledges enough packets have been received to
ensure that no data is lost.


Yes, this is how I understood sendall. But why does it sometimes report
the error: (10035, 'The socket operation could not complete without
blocking')


in this context, that error message means "I cannot buffer more data right now,
please come back later".

"sendall" (which is designed for blocking sockets) treats that as an error, while
asyncore's send and push methods do the right thing (i.e. waits until the socket
layer signals that it's ready to handle more data).

</F>

Mar 8 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael Welsh | last post by:
In order to learn sockets in Python I am trying to write a simple group chat server and client. I need a little nudge, please. My question contains some GUI but only as decoration. The root...
2
by: David Konerding | last post by:
Hello, I have written an app which opens a TCP connection to a server and uses a protocol to communicate with it. Specifically, I've written a python IMD client for the molecular dynamics...
4
by: Joshua Moore-Oliva | last post by:
Ok.. so here is my situation. I have an application that I would love to be able to use asynchat with for it's handle_close, found_terminator etc abstraction on. However, I must use a separate...
2
by: Andreas R. | last post by:
Hello, I'm using Python's asynchat for networking. If I invoke the send() method of the asynchat module, only a single send operation is possible at any given time. If I call it more than once,...
1
by: Andreas R. | last post by:
Hello, I'm using Python's asynchat module for network support in a Python-based game, and I run into two problems, both of which occur at random times. Most of the time, the network sending and...
12
by: brks | last post by:
Hi there guys and girls. I'm writing an IRC bot (even though there are loads out there that can do what I want, I love to learn-by-doing) and currently use the following to connect to the server:...
0
by: codewarrior1241 | last post by:
Hi all, I will try to be as clear as possible with my application, maybe ppl familiar with asyncore can help me out :-) Basically, I have python 2.5 in SuSe running with a server written using...
5
by: ludvig.ericson | last post by:
Hello, My question concerns asynchat in particular. With the following half- pseudo code in mind: class Example(asynchat.async_chat): def readable(self): if foo:...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.