I never thought about I/O in logging but you're right.
If i remember well some synchronized are called with "variable" lock names (see nova.virt.libvirt.connection module).
And perhaps there are (will be) synchronized which use a name based on the project/vm ...
So without cleaning, semaphores size will increase over time.
One solution is to transform semaphores into a weakref.WeakValueDictionary (beware it's not sufficient), you no more need to do the cleaning because gc will be able to do it for you.
Mainly that's what LockByKey is doing.
I never thought about I/O in logging but you're right.
If i remember well some synchronized are called with "variable" lock names (see nova.virt. libvirt. connection module).
And perhaps there are (will be) synchronized which use a name based on the project/vm ...
So without cleaning, semaphores size will increase over time.
One solution is to transform semaphores into a weakref. WeakValueDictio nary (beware it's not sufficient), you no more need to do the cleaning because gc will be able to do it for you.
Mainly that's what LockByKey is doing.