Avoid file handle exhaustion during sessions listing (see #9331).

This PR is an initial attempt at fixing an ``IOError`` that appeared when too many sessions were being purged (during ``bin/omero sessions list``). See https://trac.openmicroscopy.org.uk/ome/ticket/9331 for specific testing scenarios.