openmicroscopy/openmicroscopy — pull request #806 by manics (2013-03-05 22:57:06+00:00)
Title: Tables too many files 9996

Fixes the following issues related to [9996](https://trac.openmicroscopy.org.uk/ome/ticket/9996):
* Table files not closed when session ends. If a client didn't call `table.close()` the file handle remained open indefinitely, now `TableI.check()` checks whether the session is still active and returns `False` so that it will be destroyed by `Resources.checkAll()`.
* `TableI` not destroyed after file closed. If a client called `table.close()` the file handle was closed but the `TableI` instance remained, as seen by enabling `DEBUG` logging and observing the regular `check()` calls from closed tables.

To test: open a load of tables until `Tables-0.log` contains a too many open files error, e.g.
```
n = 0
res = session.sharedResources()
while res.newTable(0, '/test.h5'):
n += 1
print n

```
And check how many files are open (`lsof +D /OMERO_DATA_DIR/Files`) after either `client.closeSession()` is called or the session times out (may take a minute or two).

Needs reviewing by someone familiar with client/server session handling.