[Python-ideas] PEP 3156 / Tulip: Remove 'when' from Handler

Guido van Rossum guido at python.org
Tue Feb 5 16:49:43 CET 2013


I think both suggestions are good ones. The when field has bothered me
for a while, although it did not come to the surface. Adding the
call/catch/log logic on the Handler seems nice too, but I think I
would rather not use handler() -- I would rather use handler.call().
I.e. make the method name 'call', not '__call__'. (The latter almost
always makes APIs more confusing IMO.)

Can you contribute code?

--Guido

On Tue, Feb 5, 2013 at 6:48 AM, Saúl Ibarra Corretgé <saghul at gmail.com> wrote:
> Hi,
>
> While working on some changes for rose (an eventloop for tulip based on
> libuv) I realized the Handler class is a bit too coupled to the event loop
> implementation currently present in Tulip.
>
> pyuv (and pyev, and probably others) provide timers already, so there is no
> need to implement them "manually" and keep a heap with them. This basically
> means that Handler objects will always have the 'when' value set to None,
> and the comparison functions don't really apply, moreover __eq__ would even
> be incorrect in its current form.
>
> IMHO it would be good to have a base Handler class which doesn't take time
> into account and then a Timer class which does. Thoughts?
>
> Also, I see that the PEP does mention the possibility of providing a
> __call__ method on the Handler class itself, which would basically call the
> callback and suppress exceptions (I guess by logging them). Was this ever
> discussed? Sounds like a good idea to me :-)
>
>
> Regards,
>
> --
> Saúl Ibarra Corretgé
> http://saghul.net/blog | http://about.me/saghul
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas



-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list