Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #8596 (closed)

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

@login_required to call conn.c.closeSession()

Reported by: wmoore Owned by: cxallan
Priority: critical Milestone: OMERO-4.4
Component: Web Version: n.a.
Keywords: n.a. Cc: atarkowska, cneves
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2012-05-08 (14)

Description

Need to be sure we're not leaking connections.

E.g.

jrs-macbookpro-25107:OMERO will$ git diff
diff --git a/components/tools/OmeroWeb/omeroweb/decorators.py b/components/tools/OmeroWeb/omeroweb/decorators.py
index 3d6aa93..73b4884 100644
--- a/components/tools/OmeroWeb/omeroweb/decorators.py
+++ b/components/tools/OmeroWeb/omeroweb/decorators.py
@@ -273,7 +273,12 @@ class login_required(object):
             kwargs['conn'] = conn
             kwargs['conn_share'] = conn_share
             kwargs['url'] = url
-            return f(request, *args, **kwargs)
+            retval = f(request, *args, **kwargs)
+            try:
+                conn.c.closeSession()
+            except:
+                logger.error('Error while cleaning up connection.', exc_info=True)
+            return retval
         return wraps(f)(wrapped)

Change History (6)

comment:1 Changed 12 years ago by wmoore

The change suggested above breaks methods where we pass the HttpResponse? a generator that needs the session to be open. E.g:

@login_required()
def get_original_file(request, fileId, conn=None, **kwargs):
    """ Returns the specified original file as an http response. Used for displaying text or png/jpeg etc files in browser """

    # May be viewing results of a script run in a different group.
    conn.CONFIG['SERVICE_OPTS']['omero.group'] = '-1'

    orig_file = conn.getObject("OriginalFile", fileId)
    if orig_file is None:
        return handlerInternalError(request, "Original File does not exists (id:%s)." % (fileId))
    
    rsp = HttpResponse(orig_file.getFileInChunks())
    mimetype = orig_file.mimetype
    if mimetype == "text/x-python": 
        mimetype = "text/plain" # allows display in browser
    rsp['Content-Type'] =  mimetype
    rsp['Content-Length'] = orig_file.getSize()
    return rsp

Instead of displaying the original file, I get

Traceback (most recent call last):

  File "/Users/will/Desktop/OMERO/dist/lib/python/django/core/servers/basehttp.py", line 284, in run
    self.finish_response()

  File "/Users/will/Desktop/OMERO/dist/lib/python/django/core/servers/basehttp.py", line 323, in finish_response
    for data in self.result:

  File "/Users/will/Desktop/OMERO/dist/lib/python/django/http/__init__.py", line 614, in next
    chunk = self._iterator.next()

  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3670, in getFileInChunks
    store.setFileId(self._obj.id.val, self._conn.CONFIG['SERVICE_OPTS'])

  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3431, in __getattr__
    obj = self._obj or self._getObj()

  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3367, in _getObj
    self._obj = self._create_func()

  File "/Users/will/Desktop/OMERO/dist/lib/python/omero/gateway/__init__.py", line 3347, in cf
    return getattr(self._sf, self._func_str)()

  File "/Users/will/Desktop/OMERO/dist/lib/python/omero_API_ice.py", line 782, in createRawFileStore
    return _M_omero.api.ServiceFactory._op_createRawFileStore.invoke(self, ((), _ctx))

CommunicatorDestroyedException: exception ::Ice::CommunicatorDestroyedException
{
}

comment:2 Changed 12 years ago by atarkowska

  • Sprint changed from 2012-04-24 (13) to 2012-05-08 (14)

comment:3 Changed 12 years ago by cxallan

  • Remaining Time set to 0.25
  • Status changed from new to accepted

comment:4 Changed 12 years ago by cxallan

  • Remaining Time changed from 0.25 to 0
  • Resolution set to fixed
  • Status changed from accepted to closed

Functionality now up on the 8596_connection_cleaning branch:

comment:5 Changed 12 years ago by Chris Allan <callan@…>

(In [d9d0f6dd2cfbf2940e0e65eb0b10f38d5289f24f/ome.git] on branch develop) Decorator extension to clean up the connection. (See #8596)

comment:6 Changed 12 years ago by Chris Allan <callan@…>

(In [5cb110571ac7599c8c8c8789992d00661f65d51c/ome.git] on branch develop) Utilise override in webclient view methods. (See #8596)

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.68603 sec.)

We're Hiring!