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


Groups > comp.lang.python > #86555

Re: Design thought for callbacks

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fabiofz@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'falls': 0.09; 'references,': 0.09; 'url:github': 0.09; 'api': 0.11; 'cc:addr :python-list': 0.11; '(note': 0.16; '24,': 0.16; 'closures,': 0.16; 'fabio': 0.16; 'illustrate': 0.16; 'thread,': 0.16; 'top- level': 0.16; 'url:py': 0.16; 'url:pydev': 0.16; 'exception': 0.16; 'url:)': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; '(where': 0.19; 'everyone,': 0.19; 'feb': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'stick': 0.24; 'url:02': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; 'references': 0.26; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'related': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; '(on': 0.31; '25,': 0.31; 'handled': 0.32; "i'd": 0.34; 'agree': 0.35; 'created': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; "didn't": 0.36; "i'll": 0.36; 'possible': 0.36; 'should': 0.36; 'so,': 0.37; 'list': 0.37; 'list.': 0.37; 'being': 0.38; 'sometimes': 0.38; 'thank': 0.38; 'though,': 0.39; 'how': 0.40; 'read': 0.60; 'manually': 0.60; 'simple': 0.61; 'back': 0.62; 'decided': 0.64; 'different': 0.65; 'url:blogspot': 0.65; 'to:addr:gmail.com': 0.65; 'worth': 0.66; 'url:br': 0.69; 'subject:Design': 0.78; '2015': 0.84; 'everywhere.': 0.84; 'subject:thought': 0.84; 'url:master': 0.84; 'convinced': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=SdgyJI7uJXMU6C1DZJDD7378K7fo73EoRrHokW7WUD4=; b=eIteTf8d/IavPhZomFSrrfiQ49bg+gCxdgRdGsTtIXJJAMV0Vlu4QXdNs8DXhcytSJ MjTnyB5+onHWA+3nmZ6Y8hU6psqq6R7h9LEU3NNkYXaUEsyhWmwIHPD+QOfPthyqXn1W +vwbqIUswRzI6pJDWxSenWAe6mAaN44rYmwZ2I/RYrM1hThTksdP9qqd1Je01gTvZw88 bxQMqAnwxeBO7qs9PA+0MOH1nzUX0NQQ5UZ4XUrmWriREnBYgaWEnlNI1e9fSnsKnhGh oDIuoyjy9v2yzlBO8kNNEHlJSPCnhD6vzCZvhpFzrlDdIeIYsFzQv6Jet3ovRdxko00j JsYQ==
X-Received by 10.202.79.23 with SMTP id d23mr7536325oib.45.1424995484728; Thu, 26 Feb 2015 16:04:44 -0800 (PST)
MIME-Version 1.0
In-Reply-To <575FE33B-D1AD-4391-B816-7440D5849C41@gmail.com>
References <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> <CANXBEFq6dbJ-J7j4QaiR=d0pD6PfM9nsNpxYEeJ4D_vabEuucw@mail.gmail.com> <575FE33B-D1AD-4391-B816-7440D5849C41@gmail.com>
From Fabio Zadrozny <fabiofz@gmail.com>
Date Thu, 26 Feb 2015 21:04:24 -0300
Subject Re: Design thought for callbacks
To Cem Karan <cfkaran2@gmail.com>
Content-Type multipart/alternative; boundary=001a113b02ecac83e50510069d52
Cc "comp.lang.python" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.19296.1424995488.18130.python-list@python.org> (permalink)
Lines 122
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424995488 news.xs4all.nl 2848 [2001:888:2000:d::a6]:57737
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86555

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Feb 25, 2015 at 9:46 AM, Cem Karan <cfkaran2@gmail.com> wrote:

>
> On Feb 24, 2015, at 8:23 AM, Fabio Zadrozny <fabiofz@gmail.com> wrote:
>
> > Hi Cem,
> >
> > I didn't read the whole long thread, but I thought I'd point you to what
> I'm using in PyVmMonitor (http://www.pyvmmonitor.com/) -- which may
> already cover your use-case.
> >
> > Take a look at the callback.py at
> https://github.com/fabioz/pyvmmonitor-core/blob/master/pyvmmonitor_core/callback.py
> >
> > And its related test (where you can see how to use it):
> https://github.com/fabioz/pyvmmonitor-core/blob/master/_pyvmmonitor_core_tests/test_callback.py
> (note that it falls back to a strong reference on simple functions -- i.e.:
> usually top-level methods or methods created inside a scope -- but
> otherwise uses weak references).
>
> That looks like a better version of what I was thinking about originally.
> However, various people on the list have convinced me to stick with strong
> references everywhere.  I'm working out a possible API right now, once I
> have some code that I can use to illustrate what I'm thinking to everyone,
> I'll post it to the list.
>
> Thank you for showing me your code though, it is clever!
>
> Thanks,
> Cem Karan


​Hi Cem,

Well, I decided to elaborate a bit on the use-case I have and how I use it
(on a higher level):
http://pydev.blogspot.com.br/2015/02/design-for-client-side-applications-in.html

So, you can see if it may be worth for you or not (I agree that sometimes
you should keep strong references, but for my use-cases, weak references
usually work better -- with the only exception being closures, which is
handled different anyways but with the gotcha of having to manually
unregister it).

Best Regards,

Fabio​

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


Thread

Re: Design thought for callbacks Fabio Zadrozny <fabiofz@gmail.com> - 2015-02-26 21:04 -0300

csiph-web