This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fragile and unexpected error-handling in asyncore
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, giampaolo.rodola, josiah.carlson, kiilerix
Priority: normal Keywords:

Created on 2010-02-23 18:07 by kiilerix, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg99942 - (view) Author: Mads Kiilerich (kiilerix) * Date: 2010-02-23 18:07
I had an issue which seems to be very similar to issue4690 - but different.

I created a subclass of asyncore.dispatcher, .create_socket added it to the channel map, but then .bind failed (because the port was in use - my bad), .listen wasn't called, and .accepting thus not set. The problem is that .accepting is the safeguard against .handle_read and .handle_write ever being called. Without that safeguard it then started spinning in .handle_read and .handle_write, calling handlers that wasn't implemented. 

I guess the right way to handle this is to handle exceptions thrown by .bind and then call .close. But even if I do that there will be a race-condition between the error occurs and I can call .close.

My main issue/request is that asyncore should be less fragile and handle such errors better. I don't know exactly how that should be implemented, but I think it is a reasonable expectation that no handlers (except for an error handler) is called on a dispatcher until a .connect or .listen has completed. It seems odd to have to implement .handle_write just to call .send just to trigger .handle_close which then must be implemented to call .close. Perhaps a flag could keep track of the "under construction" state (instead of assuming that it is either accepting, ready to connect, or connected).

I also notice that if .handle_read_event ever gets called on a closed (listen) socket then it will end up in .handle_connect_event which is very wrong.

Using python-2.6.2-4.fc12.i686, but it seems to be the same on release2.6-maint.
msg202285 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2013-11-06 20:32
asyncore is no longer maintained, so this will not get fixed.
History
Date User Action Args
2022-04-11 14:56:58adminsetgithub: 52251
2013-11-06 20:32:53akuchlingsetstatus: open -> closed

nosy: + akuchling
messages: + msg202285

resolution: wont fix
2010-08-05 03:37:53BreamoreBoysetstage: test needed
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2010-03-14 22:26:02giampaolo.rodolasetnosy: + giampaolo.rodola, josiah.carlson
2010-02-23 18:07:42kiilerixcreate