diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-07-11 16:51:22 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-07-11 18:09:54 +0200 |
commit | fbad48f4dfee89a8b7fff64bb79e7b323a94f399 (patch) | |
tree | b8eb23bfe8fab5e7f2f352f247fa8bb11ca9aea7 /py/demo/Ice/bidir/Server.py | |
parent | - Adding comments regarding the Oracle Database demos to the (diff) | |
download | ice-fbad48f4dfee89a8b7fff64bb79e7b323a94f399.tar.bz2 ice-fbad48f4dfee89a8b7fff64bb79e7b323a94f399.tar.xz ice-fbad48f4dfee89a8b7fff64bb79e7b323a94f399.zip |
Fixed bug 2288
Diffstat (limited to 'py/demo/Ice/bidir/Server.py')
-rw-r--r-- | py/demo/Ice/bidir/Server.py | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/py/demo/Ice/bidir/Server.py b/py/demo/Ice/bidir/Server.py index 025e1df8931..1f7351436c7 100644 --- a/py/demo/Ice/bidir/Server.py +++ b/py/demo/Ice/bidir/Server.py @@ -27,7 +27,6 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): threading.Thread.__init__(self) self._communicator = communicator self._destroy = False - self._num = 0 self._clients = [] self._cond = threading.Condition() @@ -55,25 +54,36 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): self._cond.release() def run(self): - self._cond.acquire() - - try: - while not self._destroy: - self._cond.wait(2) + num = 0 - if not self._destroy and len(self._clients) > 0: - self._num = self._num + 1 + while True: - for p in self._clients[:]: # Iterate over a copy so we can modify the original list. + self._cond.acquire() + try: + self._cond.wait(2) + if self._destroy: + break + clients = self._clients[:] + finally: + self._cond.release() + + if len(clients) > 0: + num = num + 1 + + for p in clients: + try: + p.callback(num) + except: + print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" + traceback.print_exc() + + self._cond.acquire() 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() + finally: + self._cond.release() + class Server(Ice.Application): def run(self, args): adapter = self.communicator().createObjectAdapter("Callback.Server") |