asyncore: suggested patch
Robert Amesz
rcameszREMOVETHIS at dds.removethistoo.nl
Tue May 29 19:58:54 EDT 2001
Jonathan Feinberg wrote:
> rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) writes:
>
>> If Jonathan Freiberg wants to make his connect-patch work on more
>> platforms, notably Windows, he'll have to put in a bit more effort.
>
> Hmm. If Robert Azesm
Congratulations. I never saw anyone garble my last name quite as badly
as that. ;-)
> would be more specific about what part of my patch didn't work, and
> in which way it failed, I would be grateful! As for
> Windows-compatibility, I developed and tested the patch in question
> on a Windows 2K box.
Initially, I was simply concerned about the differences in error
handling between Windows sockets and Unix sockets[*], but taking a more
careful look at your patch *and* at asyncore.py I'm sorry to have to
say that your patch really totally goes against the asyncore design
principle of having a single poll-loop drive the system.
The added select() in your connection function will *block* the system.
This means that during a long wait for a connection to be established
(or time out) asyncore totally grinds to a halt. As you intend to make
a link checker, which is mostly waiting for connections and not sending
or receiving a lot of data, this is hardly the sort of behaviour you
want.
If the only thing you want to do is abort the connection attempt after
a certain amount of time it would be better just to simply check if the
connection is actually established at or after a certain point in time.
That should be straightforward enough, if you clone the loop() function
in asyncore and put the timeout-check in the 'while map:' loop.
(It might be better still if asyncore would be extended to handle
timeouts by calling two more callback-functions, say
handle_connect_timeout() and handle_io_timeout().)
OTOH, it might be simpler using multi-threading and the timeoutsocket
module.
Robert Amesz
--
[*] And I've just noticed some *really* strange bit of behaviour. I'll
describe it in another thread.
More information about the Python-list
mailing list