473,380 Members | 1,357 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,380 software developers and data experts.

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.dispatcher 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 1739

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

Similar topics

699
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...
0
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...
5
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
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...
0
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,...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.