• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 2595

Show
Ignore:
Timestamp:
07/05/08 22:16:06 (8 weeks ago)
Author:
jmoore
Message:

ticket:1018 - Fixes to omero.client but fails on destroySession()

This does not work since the context is not propagated on
router.destroySession() to session.destroy(). See:

http://www.zeroc.com/forums/help-center/2007-question-about-glacier2.html

Location:
trunk
Files:
2 modified

  • components/tools/OmeroPy/src/omero/__init__.py (modified) (6 diffs)
  • etc/grid/templates.xml (modified) (1 diff)

Legend:

Unmodified
Added
Removed
  • trunk/components/tools/OmeroPy/src/omero/__init__.py

    r2593 r2595  
    1919import omero_Constants_ice 
    2020import uuid 
     21import omero.constants 
    2122 
    2223class client(object): 
    … …  
    3940        self.of.registerObjectFactory(self.ic) 
    4041        # Define our unique identifier (used during close/detach) 
    41         self.ic.getImplicitContext().put(omero.constants.CLIENT_UUID, str(uuid.uuid4())) 
     42        self.ic.getImplicitContext().put(omero.constants.CLIENTUUID, str(uuid.uuid4())) 
    4243 
    4344    def __del__(self): 
    4445        try: 
    45             self.destroyConnection() 
     46            self.closeSession() 
    4647        except exceptions.Exception, e: 
    4748            print "Ignoring error in client.__del__:" + str(e.__class__) 
     49            traceback.print_exc() 
    4850 
    4951    def getCommunicator(self): 
    … …  
    6668    def createSession(self, username=None, password=None): 
    6769        import omero 
     70 
     71        # Check the required properties 
    6872        if not username: 
    6973            username = self.getProperty("omero.user") 
    … …  
    7983            raise ClientError("No password specified") 
    8084 
     85        # Acquire router and get the proxy 
     86        # For whatever reason, we have to set the context 
     87        # on the router context here as well. 
    8188        prx = self.ic.getDefaultRouter() 
    8289        if not prx: 
    8390            raise ClientError("No default router found.") 
     91        prx = prx.ice_context(self.ic.getImplicitContext().getContext()) 
    8492        router = Glacier2.RouterPrx.checkedCast(prx) 
    8593        if not router: 
    8694            raise ClientError("Error obtaining Glacier2 router.") 
    8795        session = router.createSession(username, password) 
     96        if not session: 
     97            raise ClientError("Obtained null object proxy") 
     98 
     99        # Check type 
    88100        self.sf = api.ServiceFactoryPrx.checkedCast(session) 
    89101        if not self.sf: 
    90             raise ClientError("No session obtained.") 
     102            raise ClientError("Obtained object proxy is not a ServiceFactory") 
    91103        return self.sf 
    92104 
    … …  
    208220 
    209221        # If 'sf' exists we remove it. 
    210         if not hasattr(self, 'sf'): 
     222        if hasattr(self, 'sf'): 
    211223            self.sf = None 
    212224 
    … …  
    215227            return 
    216228 
    217         prx = self.ic.getDefaultRouter() 
    218         router = Glacier2.RouterPrx.checkedCast(prx) 
    219  
    220         # Now destroy the actual session if possible, 
    221         # which will always trigger an exception, 
    222         # regardless of actually being connected or not 
    223         if router: 
     229        try: 
     230            prx = self.ic.getDefaultRouter() 
     231            router = Glacier2.RouterPrx.checkedCast(prx) 
     232 
     233            # Now destroy the actual session if possible, 
     234            # which will always trigger an exception, 
     235            # regardless of actually being connected or not 
     236            if router: 
     237                try: 
     238                    router.destroySession() 
     239                except exceptions.Exception, e: 
     240                    pass 
     241                    # SNEE happens if we call sf.close() before 
     242                    # calling destroySession(). CLE happens since 
     243                    # we are disconnecting 
     244 
    224245            try: 
    225                 router.destroySession() 
    226             except exceptions.Exception, e: 
    227                 pass 
    228                 # SNEE happens if we call sf.close() before 
    229                 # calling destroySession(). CLE happens since 
    230                 # we are disconnecting 
    231  
    232         try: 
    233             self.ic.destroy() 
    234         except (), msg: 
    235             pysys.stderr.write("Ice exception while destroying communicator:") 
    236             pysys.stderr.write(msg) 
    237         self.ic = None 
     246                self.ic.destroy() 
     247            except (), msg: 
     248                pysys.stderr.write("Ice exception while destroying communicator:") 
     249                pysys.stderr.write(msg) 
     250        finally: 
     251            self.ic = None 
    238252 
    239253    def _env(self, method, *args): 
  • trunk/etc/grid/templates.xml

    r2443 r2595  
    9393           <property name="Glacier2.PermissionsVerifier" value="BlitzVerifier@BlitzAdapters"/> 
    9494           <property name="Glacier2.SessionManager" value="BlitzManager@BlitzAdapters"/> 
     95           <property name="Glacier2.Client.ForwardContext" value="1"/> 
    9596           <property name="Ice.MessageSizeMax" value="4096"/> 
    9697         </properties> 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/