weakrefs and avoiding bad gc cycles
Aaron Bentley
aaron at aaronbentley.com
Tue Jun 14 19:35:55 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11-06-14 03:21 PM, Martin Pool wrote:
> On 14 June 2011 11:26, Aaron Bentley <aaron at aaronbentley.com> wrote:
>
>> On 11-06-13 05:57 PM, Martin Pool wrote:
>>> When we want to for instance
>>> assert that something is definitely closed before the end of a test,
>>> there are better deterministic ways to do it without involving gc.
>>
>> For objects where we do want to warn about failure to clean up, perhaps
>> they should register themselves with a singleton, and unregister on
>> cleanup? Then we can ask the singleton whether any items still need
>> cleanup.
>
> In production
I only meant for testing.
> when a particular bit of code finishes, we want it to
> clean up after itself. This is probably most easily done using
> addCleanup or with, hanging off something with the appropriate
> lifetime.
Agreed.
> Generally this shouldn't really hang off a real global; if
> it's something that should last as long as the bzr process there is a
> library state object.
Ah, true.
> I would probably incline away from having the global
> registry always present just in case we want to use it in the test,
> because it might impede gc and it might encourage people to keep
> things for ever.
You're right. I was thinking of something we could turn on for testing
purposes.
> Perhaps in some cases it's enough to just observe
> all the cleanups were called. For things like locks where it is
> possible to independently observe if the cleanup has been done, I
> would rather just directly check that: it avoids adding infrastructure
> and is a stronger assertion. Things like network connections where we
> can't directly observe them probably need to be tracked.
Sure.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk33uBsACgkQ0F+nu1YWqI13AQCfUbf3ukgRpvdcdkIYMMHPFr+d
aUEAnjj5gAjPOHAn2QS/ApB0segyklWF
=OPHk
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list