From 31a3ab89d621218438167b7281882553c5c1807e Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Fri, 11 Nov 2011 10:41:38 +0000 Subject: [PATCH] pull in WeakRefFinalizer fix for strongly referenced instances at sys.exit; this primarily helps pkgcore ensuring binpkg caches are flushed on the way out Package-Manager: portage-2.1.10.19/cvs/Linux x86_64 --- dev-python/snakeoil/ChangeLog | 10 +- dev-python/snakeoil/Manifest | 10 +- .../files/snakeoil-0.4.4-atexit-weakref.patch | 93 +++++++++++++++++++ dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild | 59 ++++++++++++ 4 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 dev-python/snakeoil/files/snakeoil-0.4.4-atexit-weakref.patch create mode 100644 dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild diff --git a/dev-python/snakeoil/ChangeLog b/dev-python/snakeoil/ChangeLog index 0590ea1bc569..799c2808ef6a 100644 --- a/dev-python/snakeoil/ChangeLog +++ b/dev-python/snakeoil/ChangeLog @@ -1,6 +1,14 @@ # ChangeLog for dev-python/snakeoil # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/snakeoil/ChangeLog,v 1.47 2011/10/27 07:40:26 ferringb Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/snakeoil/ChangeLog,v 1.48 2011/11/11 10:41:38 ferringb Exp $ + +*snakeoil-0.4.4-r1 (11 Nov 2011) + + 11 Nov 2011; Brian Harring +snakeoil-0.4.4-r1.ebuild, + +files/snakeoil-0.4.4-atexit-weakref.patch: + Pull in sys.exit fix for weakref finalizers; for pkgcore users, this + fixes a corner case where strong ref caches weren't being commited (thus + were regenerated every run). *snakeoil-0.4.4 (27 Oct 2011) diff --git a/dev-python/snakeoil/Manifest b/dev-python/snakeoil/Manifest index ddfaeb8e80a8..cc4053fcd78a 100644 --- a/dev-python/snakeoil/Manifest +++ b/dev-python/snakeoil/Manifest @@ -1,17 +1,19 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 +AUX snakeoil-0.4.4-atexit-weakref.patch 3111 RMD160 85ccbb38749431e4ced9a1e40ff09f2cde526351 SHA1 c203c7618376028db900dc697ff58f35580ba201 SHA256 1d13e2c17576403cfffabd3035fd37969d337d7c578494a6a9257c54d1167780 DIST snakeoil-0.4.3.tar.bz2 135763 RMD160 c8e3471778317c5c2a2a39af9e22e131df5e0426 SHA1 3625a2b7a1e924e06fc047b54b274b9b59a800cb SHA256 d533289942c369dbe7883adf684602a50082ec76347d2cbce8990cc07ad1b39f DIST snakeoil-0.4.4.tar.bz2 136039 RMD160 f8c63b458404c030e9d8cac6c4b824f7b204eb18 SHA1 92774e553d975e76777752105759727c92d2c8f4 SHA256 24d540c6f24890bb6f6a1968be0af7bfbf625a8f07785adf10c69a8263bf649d EBUILD snakeoil-0.4.3.ebuild 1503 RMD160 0aa1ea5e9f4446b722c1e78bd981a5b9fb461ca7 SHA1 0701c5b0b0d62f2024c5de27046c624ae770e7c2 SHA256 3cbdbca9b1f2e86a1bf3d753260ade5eaff57688c5203bdd6e1a2cf01ccd22d1 +EBUILD snakeoil-0.4.4-r1.ebuild 1585 RMD160 a60a72776d1eed1d64daf2500b1a99793cecd86e SHA1 6196d61284bc4133fb83610eec9317c990988e4c SHA256 8dc6a47912534f7d5a7755e1f06b564f02fa17848e1f0a55b0a885b1614f57bf EBUILD snakeoil-0.4.4.ebuild 1503 RMD160 ad4f18dfc720a8778f5722060e6d32f3c97630b4 SHA1 1a3447589523913888e753311ff56d3785d06cb8 SHA256 d4a18b20854f4488f78d260e18a39a22be5dfa03ba21374ad446fcb8b5727e62 EBUILD snakeoil-9999.ebuild 1405 RMD160 6f1c15d5ebe072730ab928ba54d03f01cad0273a SHA1 ffaa559593f934b16bfe427fc59c0778a4908702 SHA256 7fb7b4b14417e15dde2f5617d9500670820ee22e01a4af33024a89a7eb272eb4 -MISC ChangeLog 7597 RMD160 cb83f55c33a985edca1714c68685d3f0608438ff SHA1 3dc7d00502a169e132979f8110aeaca707c49ac5 SHA256 114e97292fa471eb95aa547fd96a7fef68e0cdcfe6a35399e1b5e902e2136058 +MISC ChangeLog 7933 RMD160 1b61963e82b1ff7763387264b9efdc7a61f9941f SHA1 aa9cdbeba3d8b02cc411625c0e36f29b71ad3697 SHA256 b43e9c5aefb6ded22c1eca25ece7759721309329f0edea1c6db08f7a223644ec MISC metadata.xml 240 RMD160 3f3bad3799666aa692afbe3987b28c6bb97cee16 SHA1 827a26b24276518ca921812f32c5c84947261047 SHA256 c2b67eb9d86d19e854bdf3ef9e98fa52f8bc550ae2359c419b540c26ebb0b438 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) -iEYEARECAAYFAk6pCu8ACgkQsiLx3HvNzgcnGACbBGbNei55k3Ysh8Evmca2dJOG -iaQAmQFHMjvWmfQGCySZ1lDUcG7wY0wZ -=9YJQ +iEYEARECAAYFAk68++cACgkQsiLx3HvNzgf1BACgyJF/AX+g0bRvi6lzXHHNQ9cL +DtIAnjcyd+2M4fi97cx1iUrhi3og5W80 +=51eG -----END PGP SIGNATURE----- diff --git a/dev-python/snakeoil/files/snakeoil-0.4.4-atexit-weakref.patch b/dev-python/snakeoil/files/snakeoil-0.4.4-atexit-weakref.patch new file mode 100644 index 000000000000..1ca7ca102c98 --- /dev/null +++ b/dev-python/snakeoil/files/snakeoil-0.4.4-atexit-weakref.patch @@ -0,0 +1,93 @@ +From 2ad8113511381ae502a000809700cb672c073f92 Mon Sep 17 00:00:00 2001 +From: Brian Harring +Date: Fri, 11 Nov 2011 02:04:43 -0800 +Subject: [PATCH] WeakRefFinalizer: use atexit to cleanup any strongly + referenced instances at sys.exit + +--- + NEWS | 4 ++++ + snakeoil/weakrefs.py | 23 ++++++++++++++++++++--- + 2 files changed, 24 insertions(+), 3 deletions(-) + +diff --git a/NEWS b/NEWS +index 04015ee..4fbfb0e 100644 +--- a/NEWS ++++ b/NEWS +@@ -2,6 +2,10 @@ Snakeoil Release Notes + ====================== + + ++* Fix WeakRefFinalizer so that instances that are still strongly referenced ++ at the time of sys.exit have their finalizers ran via atexit. ++ ++ + snakeoil 0.4.4: Oct 26th, 2011 + + * use sane permissions for directories created for tests. +diff --git a/snakeoil/weakrefs.py b/snakeoil/weakrefs.py +index 1a25a9c..272b4d3 100644 +--- a/snakeoil/weakrefs.py ++++ b/snakeoil/weakrefs.py +@@ -10,13 +10,15 @@ __all__ = ("WeakValCache", "WeakRefFinalizer") + # Unused import + # pylint: disable-msg=W0611 + ++import atexit ++ + try: + # No name in module + # pylint: disable-msg=E0611 + from snakeoil._caching import WeakValCache +- from weakref import ref ++ from weakref import ref, WeakKeyDictionary + except ImportError: +- from weakref import WeakValueDictionary as WeakValCache, ref ++ from weakref import WeakValueDictionary as WeakValCache, ref, WeakKeyDictionary + + from snakeoil.obj import make_kls, BaseDelayedObject + from snakeoil.currying import partial +@@ -38,7 +40,6 @@ class WeakRefProxy(BaseDelayedObject): + obj.__enable_finalization__(weakref) + return obj + +- + def __enable_finalization__(self, weakref): + # note we directly access the class, to ensure the instance hasn't overshadowed. + self.__class__.__finalizer_weakrefs__[id(self)] = weakref +@@ -116,6 +117,9 @@ class WeakRefFinalizer(type): + >>> del obj + finalization invoked: bar + """ ++ ++ __known_classes__ = WeakKeyDictionary() ++ + def __new__(cls, name, bases, d): + if '__del__' in d: + d['__finalizer__'] = d.pop("__del__") +@@ -137,6 +141,7 @@ class WeakRefFinalizer(type): + new_cls = super(WeakRefFinalizer, cls).__new__(cls, name, bases, d) + new_cls.__proxy_class__ = partial(make_kls(new_cls, WeakRefProxy), cls, lambda x:x) + new_cls.__proxy_class__.__name__ = name ++ cls.__known_classes__[new_cls] = True + return new_cls + + def __call__(cls, *a, **kw): +@@ -146,3 +151,15 @@ class WeakRefFinalizer(type): + # weakref registration + getattr(proxy, '__finalizer__') + return proxy ++ ++ @classmethod ++ def _atexit_cleanup(cls): ++ # cleanup any instances strongly referenced at the time of sys.exit ++ target_classes = cls.__known_classes__.keys() ++ for target_cls in target_classes: ++ for target_ref in target_cls.__finalizer_weakrefs__.values(): ++ obj = target_ref() ++ if obj is not None: ++ obj.__finalizer__() ++ ++atexit.register(WeakRefFinalizer._atexit_cleanup) +-- +1.7.8.rc1 + diff --git a/dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild b/dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild new file mode 100644 index 000000000000..cabbd5622b69 --- /dev/null +++ b/dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild @@ -0,0 +1,59 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/snakeoil/snakeoil-0.4.4-r1.ebuild,v 1.1 2011/11/11 10:41:38 ferringb Exp $ + +EAPI="2" +SUPPORT_PYTHON_ABIS="1" + +inherit distutils eutils + +DESCRIPTION="Miscellaneous python utility code." +HOMEPAGE="http://snakeoil.googlecode.com/" +SRC_URI="http://snakeoil.googlecode.com/files/${P}.tar.bz2" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86" +IUSE="" + +DEPEND="!