Skip to content

Commit

Permalink
Merge pull request ome#5781 from joshmoore/unclosed-communicator
Browse files Browse the repository at this point in the history
Close communicator after a failed session creation
  • Loading branch information
joshmoore authored Jun 22, 2018
2 parents bcc3841 + c7d76db commit ffa5419
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions components/tools/OmeroPy/src/omero/util/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,24 +342,28 @@ def create(self, name, pasw, props, new=True, set_current=True, sudo=None):
client = omero.client(props)
client.setAgent("OMERO.sessions")

if sudo is not None:
sf = client.createSession(sudo, pasw)
principal = omero.sys.Principal()
principal.name = name
principal.group = props.get("omero.group", None)
principal.eventType = "User"

# Retrieve the default time to idle value
uuid = sf.ice_getIdentity().name
sess = sf.getSessionService().getSession(uuid)
timeToIdle = sess.getTimeToIdle().getValue()

sess = sf.getSessionService().createSessionWithTimeouts(
principal, 0, timeToIdle)
client.closeSession()
sf = client.joinSession(sess.getUuid().getValue())
else:
sf = client.createSession(name, pasw)
try:
if sudo is not None:
sf = client.createSession(sudo, pasw)
principal = omero.sys.Principal()
principal.name = name
principal.group = props.get("omero.group", None)
principal.eventType = "User"

# Retrieve the default time to idle value
uuid = sf.ice_getIdentity().name
sess = sf.getSessionService().getSession(uuid)
timeToIdle = sess.getTimeToIdle().getValue()

sess = sf.getSessionService().createSessionWithTimeouts(
principal, 0, timeToIdle)
client.closeSession()
sf = client.joinSession(sess.getUuid().getValue())
else:
sf = client.createSession(name, pasw)
except:
client.__del__()
raise

ec = sf.getAdminService().getEventContext()
uuid = sf.ice_getIdentity().name
Expand Down

0 comments on commit ffa5419

Please sign in to comment.