Changeset 2595
- Timestamp:
- 07/05/08 22:16:06 (8 weeks ago)
- 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 19 19 import omero_Constants_ice 20 20 import uuid 21 import omero.constants 21 22 22 23 class client(object): … … 39 40 self.of.registerObjectFactory(self.ic) 40 41 # 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())) 42 43 43 44 def __del__(self): 44 45 try: 45 self. destroyConnection()46 self.closeSession() 46 47 except exceptions.Exception, e: 47 48 print "Ignoring error in client.__del__:" + str(e.__class__) 49 traceback.print_exc() 48 50 49 51 def getCommunicator(self): … … 66 68 def createSession(self, username=None, password=None): 67 69 import omero 70 71 # Check the required properties 68 72 if not username: 69 73 username = self.getProperty("omero.user") … … 79 83 raise ClientError("No password specified") 80 84 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. 81 88 prx = self.ic.getDefaultRouter() 82 89 if not prx: 83 90 raise ClientError("No default router found.") 91 prx = prx.ice_context(self.ic.getImplicitContext().getContext()) 84 92 router = Glacier2.RouterPrx.checkedCast(prx) 85 93 if not router: 86 94 raise ClientError("Error obtaining Glacier2 router.") 87 95 session = router.createSession(username, password) 96 if not session: 97 raise ClientError("Obtained null object proxy") 98 99 # Check type 88 100 self.sf = api.ServiceFactoryPrx.checkedCast(session) 89 101 if not self.sf: 90 raise ClientError(" No session obtained.")102 raise ClientError("Obtained object proxy is not a ServiceFactory") 91 103 return self.sf 92 104 … … 208 220 209 221 # If 'sf' exists we remove it. 210 if nothasattr(self, 'sf'):222 if hasattr(self, 'sf'): 211 223 self.sf = None 212 224 … … 215 227 return 216 228 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 224 245 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 238 252 239 253 def _env(self, method, *args): -
trunk/etc/grid/templates.xml
r2443 r2595 93 93 <property name="Glacier2.PermissionsVerifier" value="BlitzVerifier@BlitzAdapters"/> 94 94 <property name="Glacier2.SessionManager" value="BlitzManager@BlitzAdapters"/> 95 <property name="Glacier2.Client.ForwardContext" value="1"/> 95 96 <property name="Ice.MessageSizeMax" value="4096"/> 96 97 </properties>
