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 8 2597
"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_prod ucer").
</F>
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_prod ucer").
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
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
misunderstandin g 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 misunderstandin g
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_produ cer 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
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.pytho n:
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
(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>
"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_prod ucer"). 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>
"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> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 question is asyncore / asynchat. I
have read that twisted makes this all simple, but, I wanted to get my hands
dirty here for educational purposes.
I've managed to build a small echo server with asyncore and asynchat that can
handle any number of...
|
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 application 'NAMD' (do searches for IMD and NAMD if you want to learn more).
The protocol is very simple: both ends of the TCP connection can send messages to the other side at any time; when data is
available on a read socket, a full packet (with known...
|
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 thread for each connection as the work resulting from the communication can result in blocking for an indefinate period of time.
What I would love to do for each thread that is created, is to spin off an asynchat subclass and manually run some...
|
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, only the first call is
registered at the other client.
So how do I fix this? Do I have to use select etc.?
The source code is here:
|
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 receiving is perfect, but
about 1 out of 10 times, it fails with one of these errors:
-- Problem 1. When sending data, I sometimes the following exception:
Handler connected 127.0.0.1:1242 at 0x2977800> (socket.error:(9, 'Bad
file descriptor')
| |
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:
import sys, string, os
import socket, asyncore, asynchat
from irc_config import *
from irc_parse import *
from irc_modules import *
#from irc_connect import *
|
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 asynchat. I use it to connect to several clients inside the asyncore.loop construct.
This part of the application works fine. However, along with talking to clients through sockets, I need to talk to some Spread groups, obviously using spread. My...
|
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:
self.push_with_producer(ProducerA())
return asynchat.async_chat.readable(self)
|
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 I
don't see the error):
"System.IO.IOException: Unable to read data from the transport connection:A
blocking operation was interrupted by a call to WSACancelBlockingCall"
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |