I have been playing with possible solutions for a while and the weak-reference solution seems not robust enough as there are too potential race conditions between the destruction of the weakreferences (the pool) and the handling code.
I would advocate again for using a strong reference. The reasons are:
* The rest of the stdlib is using this solution to link iterator objects and similar to their parents (lists, dicts, sets...etc all have strong references back to their parents).
* This solution is backwards compatible with the current behaviour.
* We have the new ResourceWarnigns to make clear that this behaviour is not supported. |