Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86038

Re: Design thought for callbacks

References <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <CAPTjJmpEHQV2PpaZvszuTGn0_GNg0sWV6aLenbQsZrSXCy2YKQ@mail.gmail.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date 2015-02-21 06:24 -0800
Subject Re: Design thought for callbacks
Newsgroups comp.lang.python
Message-ID <mailman.18965.1424528721.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Feb 20, 2015 at 9:42 PM, Chris Angelico <rosuav@gmail.com> wrote:
> No, it's not. I would advise using strong references - if the callback
> is a closure, for instance, you need to hang onto it, because there
> are unlikely to be any other references to it. If I register a
> callback with you, I expect it to be called; I expect, in fact, that
> that *will* keep my object alive.

For that matter, if the callback is a method, you need to hang onto
it, because method wrappers are generated on demand, so the method
would be removed from the valid callbacks instantly.

Weak references for callbacks are broken.

-- Devin

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Design thought for callbacks Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-02-21 06:24 -0800

csiph-web