On Thu, Jul 03, 2014 at 04:19:16PM -0700, Guido van Rossum wrote:
> [...] occasionally remove cancelled timers from the heapq. [...]
> 
> That approach wouldn't deal with non-timer Handlers that are cancelled, but
> I'm not sure how common that use case is (the OP specifically mentioned
> timeouts).

it struck me with timeouts. the handles created by selectors seem to
drop the references to its handle at removal time. still, other users of
Handle might not be so clever, and might rely on .cancel() to clean up.

such a heapq cleanup could be a performance improvement at best (if
handlers are thoroughly cleared at cancellation, it only frees some
items in the list that would otherwise be freed after the timeout in
front of them fires). for implementations of unit tests that test
whether an object to be freed, that would still need to be triggered
manually, an i doubt that people will find that before they try wiping
timeouts they cancel.

> I've got a feeling that occasionally it might be useful to have the
> callback+args show up in a handler's repr(), even if it is cancelled, but
> I'm not sure how valuable that is in practice.

i did consider this, but such repr data is supposed to ease debugging,
not make it harder. after all, when you cancelled a timeout, you can't
expect it to be of any use any more.

(the behavior of showing the repr could be retained by eagerly
evaluating repr or using weakrefs, but it wouldn't be work the hassle; i
prefer to think of cancelled objects as dead-and-gone)

best regards
chrysn

-- 
There's always a bigger fish.
  -- Qui-Gon Jinn

Attachment: signature.asc
Description: Digital signature

Reply via email to