bigfile/zodb: Do not hold reference to ZBigFileH indefinitely in Connection.onOpenCallback
If we do - ZBigFileH objects just don't get garbage collected, and sooner or later this way it leaks enough filedescriptors so that main zope loop breaks: Traceback (most recent call last): File ".../bin/runzope", line 194, in <module> sys.exit(Zope2.Startup.run.run()) File ".../eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/run.py", line 26, in run starter.run() File ".../eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/__init__.py", line 105, in run Lifetime.loop() File ".../eggs/Zope2-2.13.22-py2.7.egg/Lifetime/__init__.py", line 43, in loop lifetime_loop() File ".../eggs/Zope2-2.13.22-py2.7.egg/Lifetime/__init__.py", line 53, in lifetime_loop asyncore.poll(timeout, map) File ".../parts/python2.7/lib/python2.7/asyncore.py", line 145, in poll r, w, e = select.select(r, w, e, timeout) ValueError: filedescriptor out of range in select() $ lsof -p <runzope-pid> |grep ramh | wc -l 950 So continuing 64d1f40b (bigfile/zodb: Monkey-patch for ZODB.Connection to support callback on .open()) let's change the implementation to use WeakSet for callbacks list. Yes, because weakref to bound methods release immediately, we give up flexibility to subscribe to arbitrary callbacks. If it become an issue, something like WeakMethod from py3 or recipes from the net how to do it are there.
Showing with 39 additions and 3 deletions