473,791 Members | 3,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python 2.4, asyncore and errors

Changes in asyncore from 2.3 to 2.4 mean that asyncore.poll() now passes all
the sockets in the map to select.select() to be checked for errors, which is
probably a good thing. If an error occurs, then handle_expt() is called,
which by default logs the error.

asyncore.dispat cher creates nonblocking sockets. When connect_ex() is
called on a nonblocking socket, it will probably return EWOULDBLOCK
(connecting takes time), which may mean the connection is successful, or may
not (asyncore dispatcher keeps going assuming all is well).

If the connection is not successful, and then asyncore.loop() is called,
then select.select() will indicate that there is an error with the socket
(can't connect) and the error will be logged.

The trouble is that asyncore.loop then keeps going, and will log this error
again. My not-that-fast system here gets about 10,000 logged messages per
second with a single socket in the asyncore map.

There are ways to avoid this:

(1) if the socket is blocking when connect()ing (and then nonblocking
afterwards) an error is raised if the connect fails.

(2) Before calling asyncore.loop() , the caller can run through all the
sockets, checking that they are ok.

(3) handle_expt() can be overridden with a function that repairs or
removes the socket from the map (etc)

However, I'm not convinced that this is good behavior for asyncore to have,
by default. On Windows, select.select() will only indicate an error when
trying to connect (nonblocking) or if SO_OOBINLINE is disabled, but this may
not be the case (i.e. errors can occur at other times) with other platforms,
right? Unless the error is temporary, asyncore will by default start
streaming (extremely fast) a lot of "warning: unhandled exception" (not very
helpful an error message, either) messages. Even if the error only lasts a
minute, that could easily result in 10,000 warnings being logged.

Does anyone else agree that this should be changed? If so, what should be
the correct behavior? (I'm happy to work up a patch and submit it).

=Tony.Meyer

Jul 18 '05 #1
0 1759

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

Similar topics

699
34255
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
0
1301
by: Z. Kotzer | last post by:
I can not get error notifications when an asynchat based client tries to connect to a non-responsive address. To validate the problem I changed lib/test/test_asynchat.py as follows: class echo_client(asynchat.async_chat): def __init__(self): asynchat.async_chat.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
5
2792
by: Linan | last post by:
Hi, In javascript, code could be written like this: .... var _p=XMLHttpRequest(); _p.open('GET',url,true); _p.send(null); _p.onreadystateChange=function(){
0
330
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 380 open (-36) / 3658 closed (+65) / 4038 total (+29) Bugs : 965 open ( -9) / 6555 closed (+35) / 7520 total (+26) RFE : 272 open ( +4) / 253 closed ( +2) / 525 total ( +6) New / Reopened Patches ______________________
0
1775
by: GeicoGecko | last post by:
Hey guys, There was no python section in the "Web Development" forum so I'm hoping I can pose my question in here. Our system We currently have a python webserver using SimpleHTTPServer, asyncore and asynchat. This server has worked well for us but now that we have multiple connections to the server, the non-threaded asyncore has been pushed to it's limit and connections are being rejected and sockets are being closed. As a result we...
0
1364
by: davy zhang | last post by:
I wrote this server to handle incoming messages in a process using multiprocessing named "handler", and sending message in a Thread named "sender", 'cause I think the async_chat object can not pass between processes. My project is a network gate server with many complex logic handler behind, so I use multiprocessing to handle them separately and send back the clients later when done. To use the server multicore cpu I tried to separate...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10428
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, 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...
1
10156
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,...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
3
2916
bsmnconsultancy
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...

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.