ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
20 stars 33 forks source link

Convert functions returning a handle that needs to be closed into a ContextManager #265

Closed manics closed 3 years ago

manics commented 3 years ago

For example, omero.cilent.submit() returns a handle that needs to be closed to avoid a resource leak: https://github.com/ome/omero-py/blob/c62def8fbb33bd89827623f7c0e1f69e88d07182/src/omero/clients.py#L994-L1001

We could make it easier to use by turning it into a ContextManager, which also clearly documents that it needs to be closed. This could be done either by adding an argument to the existing method, or by adding a new method.

This also applies to other methods, including some related to rendering.

manics commented 3 years ago

This is a dupe 😄 https://github.com/ome/omero-py/issues/153