diff options
Diffstat (limited to 'py/demo/Ice/bidir/Server.py')
-rw-r--r-- | py/demo/Ice/bidir/Server.py | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/py/demo/Ice/bidir/Server.py b/py/demo/Ice/bidir/Server.py index 68e983f7c91..05dfbaf7f88 100644 --- a/py/demo/Ice/bidir/Server.py +++ b/py/demo/Ice/bidir/Server.py @@ -25,68 +25,68 @@ import Demo class CallbackSenderI(Demo.CallbackSender, threading.Thread): def __init__(self, communicator): - threading.Thread.__init__(self) - self._communicator = communicator - self._destroy = False - self._num = 0 - self._clients = [] - self._cond = threading.Condition() + threading.Thread.__init__(self) + self._communicator = communicator + self._destroy = False + self._num = 0 + self._clients = [] + self._cond = threading.Condition() def destroy(self): - self._cond.acquire() + self._cond.acquire() - print "destroying callback sender" - self._destroy = True + print "destroying callback sender" + self._destroy = True - try: - self._cond.notify() - finally: - self._cond.release() + try: + self._cond.notify() + finally: + self._cond.release() - self.join() + self.join() def addClient(self, ident, current=None): - self._cond.acquire() + self._cond.acquire() print "adding client `" + self._communicator.identityToString(ident) + "'" - client = Demo.CallbackReceiverPrx.uncheckedCast(current.con.createProxy(ident)) - self._clients.append(client) + client = Demo.CallbackReceiverPrx.uncheckedCast(current.con.createProxy(ident)) + self._clients.append(client) - self._cond.release() + self._cond.release() def run(self): - self._cond.acquire() + self._cond.acquire() - try: - while not self._destroy: - self._cond.wait(2) + try: + while not self._destroy: + self._cond.wait(2) - if not self._destroy and len(self._clients) > 0: - self._num = self._num + 1 + if not self._destroy and len(self._clients) > 0: + self._num = self._num + 1 - for p in self._clients[:]: # Iterate over a copy so we can modify the original list. - try: - p.callback(self._num) - except: - print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" - traceback.print_exc() - self._clients.remove(p) - finally: - self._cond.release() + for p in self._clients[:]: # Iterate over a copy so we can modify the original list. + try: + p.callback(self._num) + except: + print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" + traceback.print_exc() + self._clients.remove(p) + finally: + self._cond.release() class Server(Ice.Application): def run(self, args): adapter = self.communicator().createObjectAdapter("Callback.Server") - sender = CallbackSenderI(self.communicator()) + sender = CallbackSenderI(self.communicator()) adapter.add(sender, self.communicator().stringToIdentity("sender")) adapter.activate() - sender.start() - try: - self.communicator().waitForShutdown() - finally: - sender.destroy() + sender.start() + try: + self.communicator().waitForShutdown() + finally: + sender.destroy() return 0 |