summaryrefslogtreecommitdiff
path: root/py/demo/IceGrid/allocate/Client.py
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2006-08-21 10:49:08 +0000
committerMatthew Newhook <matthew@zeroc.com>2006-08-21 10:49:08 +0000
commit514565002ea6c54b9c2cd59f7b4f033dbc8cbe33 (patch)
tree44108033a51217d714b6ed9fb077848e005501d3 /py/demo/IceGrid/allocate/Client.py
parenthttp://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1303' CVS: (diff)
downloadice-514565002ea6c54b9c2cd59f7b4f033dbc8cbe33.tar.bz2
ice-514565002ea6c54b9c2cd59f7b4f033dbc8cbe33.tar.xz
ice-514565002ea6c54b9c2cd59f7b4f033dbc8cbe33.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=1303
Diffstat (limited to 'py/demo/IceGrid/allocate/Client.py')
-rw-r--r--py/demo/IceGrid/allocate/Client.py72
1 files changed, 37 insertions, 35 deletions
diff --git a/py/demo/IceGrid/allocate/Client.py b/py/demo/IceGrid/allocate/Client.py
index 716c1863573..fcfeb19ec8a 100644
--- a/py/demo/IceGrid/allocate/Client.py
+++ b/py/demo/IceGrid/allocate/Client.py
@@ -54,6 +54,7 @@ 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"
@@ -72,48 +73,49 @@ class Client(Ice.Application):
keepAlive = SessionKeepAliveThread(session, registry.getSessionTimeout() / 2)
keepAlive.start()
- hello = None
try:
- hello = Demo.HelloPrx.checkedCast(session.allocateObjectById(self.communicator().stringToIdentity("hello")))
+ try:
+ hello = Demo.HelloPrx.checkedCast(\
+ session.allocateObjectById(self.communicator().stringToIdentity("hello")))
+ except IceGrid.ObjectNotRegisteredException:
+ hello = Demo.HelloPrx.checkedCast(session.allocateObjectByType("::Demo::Hello"))
+
+ menu()
+
+ c = None
+ while c != 'x':
+ try:
+ c = raw_input("==> ")
+ if c == 't':
+ hello.sayHello()
+ elif c == 's':
+ hello.shutdown()
+ elif c == 'x':
+ pass # Nothing to do
+ elif c == '?':
+ menu()
+ else:
+ print "unknown command `" + c + "'"
+ menu()
+ except EOFError:
+ break
except IceGrid.AllocationException, ex:
print self.appName() + ": could not allocate object: " + ex.reason
- return False
- except IceGrid.ObjectNotRegisteredException:
- pass
- if hello == None:
- try:
- hello = Demo.HelloPrx.checkedCast(session.allocateObjectByType("::Demo::Hello"))
- except IceGrid.AllocationException, ex:
- print self.appName() + ": could not allocate object: " + ex.reason
- return False
-
- menu()
-
- c = None
- while c != 'x':
- try:
- c = raw_input("==> ")
- if c == 't':
- hello.sayHello()
- elif c == 's':
- hello.shutdown()
- elif c == 'x':
- pass # Nothing to do
- elif c == '?':
- menu()
- else:
- print "unknown command `" + c + "'"
- menu()
- except EOFError:
- break
-
+ 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.releaseObject(hello.ice_getIdentity())
session.destroy();
- return True
+ return status
app = Client()
sys.exit(app.main(sys.argv, "config.client"))