I'd suggest the following:
- Code: Select all
try:
client = omero.script.client(...)
gateway = client.sf.createGateway()
try:
... do work
finally:
gateway.close()
finally:
client.closeSession()
closeSession() is the session level close you are looking for. Notice that
http://hudson.openmicroscopy.org.uk/job/OMERO/javadoc/slice2html/omero/api/ServiceFactory.html#close is deprecated.
Closing the gateway before closing the session is mostly good form, but there's also an element of conserving resources. Even though you call closeSession, the server has an extra reference to your session so that it can retrieve your values, and so the session won't truly be removed until the reference count goes to zero. So
always, always close services like gateway when possible.
~Josh.