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.

Author kiilerix
Recipients kiilerix
Date 2010-02-23.18:07:41
SpamBayes Score 1.3592327e-05
Marked as misclassified No
Message-id <1266948464.33.0.330812797821.issue8003@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-02-23 18:07:44kiilerixsetrecipients: + kiilerix
2010-02-23 18:07:44kiilerixsetmessageid: <1266948464.33.0.330812797821.issue8003@psf.upfronthosting.co.za>
2010-02-23 18:07:42kiilerixlinkissue8003 messages
2010-02-23 18:07:41kiilerixcreate