diff options
Diffstat (limited to 'py/demo/IceGrid/sessionActivation')
-rw-r--r-- | py/demo/IceGrid/sessionActivation/Client.py | 108 | ||||
-rw-r--r-- | py/demo/IceGrid/sessionActivation/Server.py | 12 |
2 files changed, 60 insertions, 60 deletions
diff --git a/py/demo/IceGrid/sessionActivation/Client.py b/py/demo/IceGrid/sessionActivation/Client.py index 78cb1ee6130..3710280f11d 100644 --- a/py/demo/IceGrid/sessionActivation/Client.py +++ b/py/demo/IceGrid/sessionActivation/Client.py @@ -35,11 +35,11 @@ class SessionKeepAliveThread(threading.Thread): while not self._terminated: self._cond.wait(self._timeout) if self._terminated: - break + break try: self._session.keepAlive() except Ice.LocalException, ex: - break + break finally: self._cond.release() @@ -53,67 +53,67 @@ class SessionKeepAliveThread(threading.Thread): class Client(Ice.Application): def run(self, args): - status = True - registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) - if registry == None: - print self.appName() + ": could not contact registry" - return False + status = True + registry = IceGrid.RegistryPrx.checkedCast(self.communicator().stringToProxy("DemoIceGrid/Registry")) + if registry == None: + print self.appName() + ": could not contact registry" + return False - while True: - print "This demo accepts any user-id / password combination." - id = raw_input("user id: ").strip() - pw = raw_input("password: ").strip() - try: - session = registry.createSession(id, pw) - break - except IceGrid.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason + while True: + print "This demo accepts any user-id / password combination." + id = raw_input("user id: ").strip() + pw = raw_input("password: ").strip() + try: + session = registry.createSession(id, pw) + break + except IceGrid.PermissionDeniedException, ex: + print "permission denied:\n" + ex.reason - keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) - keepAlive.start() + keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2) + keepAlive.start() - try: - hello = Demo.HelloPrx.checkedCast(session.allocateObjectById(self.communicator().stringToIdentity("hello"))) + try: + hello = Demo.HelloPrx.checkedCast(session.allocateObjectById(self.communicator().stringToIdentity("hello"))) - menu() + menu() - c = None - while c != 'x': - try: - c = raw_input("==> ") - if c == 't': - hello.sayHello() - elif c == 'x': - pass # Nothing to do - elif c == '?': - menu() - else: - print "unknown command `" + c + "'" - menu() - except EOFError: - break - except KeyboardInterrupt: - break - except IceGrid.AllocationException, ex: - print self.appName() + ": could not allocate object: " + ex.reason - status = False - except IceGrid.ObjectNotRegisteredException: - print self.appName() + ": object not registered with registry" - status = False - except: + c = None + while c != 'x': + try: + c = raw_input("==> ") + if c == 't': + hello.sayHello() + elif c == 'x': + pass # Nothing to do + elif c == '?': + menu() + else: + print "unknown command `" + c + "'" + menu() + except EOFError: + break + except KeyboardInterrupt: + break + except IceGrid.AllocationException, ex: + print self.appName() + ": could not allocate object: " + ex.reason + status = False + except IceGrid.ObjectNotRegisteredException: + print self.appName() + ": object not registered with registry" + status = False + except: print self.appName() + ": could not allocate object: " + str(sys.exc_info()[0]) status = False - # - # Destroy the keepAlive thread and the sesion object otherwise - # the session will be kept allocated until the timeout occurs. - # Destroying the session will release all allocated objects. - # - keepAlive.terminate() - keepAlive.join() - session.destroy(); + # + # Destroy the keepAlive thread and the sesion object otherwise + # the session will be kept allocated until the timeout occurs. + # Destroying the session will release all allocated objects. + # + keepAlive.terminate() + keepAlive.join() + session.destroy(); - return status + return status app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/IceGrid/sessionActivation/Server.py b/py/demo/IceGrid/sessionActivation/Server.py index 6e2a8738be6..d4e4008a98d 100644 --- a/py/demo/IceGrid/sessionActivation/Server.py +++ b/py/demo/IceGrid/sessionActivation/Server.py @@ -23,12 +23,12 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): properties = self.communicator().getProperties() - adapter = self.communicator().createObjectAdapter("Hello") - id = self.communicator().stringToIdentity(properties.getProperty("Identity")) - adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) - adapter.activate() - self.communicator().waitForShutdown() - return 0 + adapter = self.communicator().createObjectAdapter("Hello") + id = self.communicator().stringToIdentity(properties.getProperty("Identity")) + adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id) + adapter.activate() + self.communicator().waitForShutdown() + return 0 app = Server() sys.exit(app.main(sys.argv)) |