Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'falls': 0.09; 'url:github': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; '(note': 0.16; '24,': 0.16; 'fabio': 0.16; 'illustrate': 0.16; 'thread,': 0.16; 'top-level': 0.16; 'url:py': 0.16; 'url:)': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; '(where': 0.19; 'everyone,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'stick': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'references': 0.26; 'post': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'related': 0.29; "i'm": 0.30; 'code': 0.31; 'usually': 0.31; "i'd": 0.34; 'created': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; "i'll": 0.36; 'possible': 0.36; 'list': 0.37; 'list.': 0.37; 'message-id:@gmail.com': 0.38; 'thank': 0.38; 'though,': 0.39; 'how': 0.40; 'read': 0.60; 'simple': 0.61; 'back': 0.62; 'header:Message-Id:1': 0.63; 'to:addr:gmail.com': 0.65; 'subject:Design': 0.78; '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=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=6twWeZkdzuYeRWMz72TPprcLTpavQaFngEIjoIOJtnk=; b=OvfCW0g30Ku3CI4l4PEEJRktIepwvs7yWhwODaokwqQUMTLQzRSZu8ER4aq6S449qZ XnL8jSi6NN1bCv53ujgJS0SGgeTStXBeOcVGiBR7wPBP335E9cWv4uVo7DA/mXyZaWT1 GOWcI00RDsFVMyI0VFnwOCQPzNvZkhuJJ/DVeybiHLLQbopztoDX61ZucLGDWeuHFTdR q7ioInU+X/oXdhGy11tWiHIKABU1dmqm8AZrO62I/OC1aNvBBXG+eXC0lQj+LnnezTB5 aKin4Q00wxD0z1QBEJzsOvVx6GivWoAkh79tKCIRb6gkCKnnWDjKwHJEOdDsxDRPddig AIAQ== X-Received: by 10.52.128.172 with SMTP id np12mr3787453vdb.92.1424868380796; Wed, 25 Feb 2015 04:46:20 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Design thought for callbacks From: Cem Karan In-Reply-To: Date: Wed, 25 Feb 2015 07:46:19 -0500 Content-Transfer-Encoding: quoted-printable References: <33677AE8-B2FA-49F9-9304-C8D93784255D@gmail.com> To: Fabio Zadrozny X-Mailer: Apple Mail (2.1510) Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424868383 news.xs4all.nl 2958 [2001:888:2000:d::a6]:50804 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86396 On Feb 24, 2015, at 8:23 AM, Fabio Zadrozny wrote: > Hi Cem, >=20 > 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. >=20 > Take a look at the callback.py at = https://github.com/fabioz/pyvmmonitor-core/blob/master/pyvmmonitor_core/ca= llback.py >=20 > And its related test (where you can see how to use it): = https://github.com/fabioz/pyvmmonitor-core/blob/master/_pyvmmonitor_core_t= ests/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=