From: Eric C. N. <eri...@us...> - 2002-05-09 19:08:01
|
Update of /cvsroot/recall/corba/src/Recall In directory usw-pr-cvs1:/tmp/cvs-serv22866/src/Recall Modified Files: CorbaUtil.py Log Message: make publisher a util, to use in the demo Index: CorbaUtil.py =================================================================== RCS file: /cvsroot/recall/corba/src/Recall/CorbaUtil.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CorbaUtil.py 9 May 2002 14:16:19 -0000 1.11 --- CorbaUtil.py 9 May 2002 19:01:38 -0000 1.12 *************** *** 1,4 **** --- 1,6 ---- "CORBA utilities" + from Recall import Thread + import CORBA CosNaming = CORBA.CosNaming *************** *** 28,37 **** raise socket.error('Cannot listen on socket %s:%d' % (host, port)) ! def publisher(host, port, ior): ! s = listen(host, port) ! while 1: ! c, a = s.accept() ! c.send(ior) ! c.close() class Contexts: --- 30,55 ---- raise socket.error('Cannot listen on socket %s:%d' % (host, port)) ! class Publisher(Thread.Thread): ! ! def __init__(self, *args, **kwargs): ! Thread.Thread.__init__(self) ! self.args = args ! ! def run(self): ! import select ! host, port, ior = self.args ! print port ! s = listen(host, port) ! s.setblocking(0) ! try: ! while not self.testStop(): ! rd, wr, ex = select.select([s], [], [], 1.0) ! if rd: ! c, a = s.accept() ! c.send(ior) ! c.close() ! finally: ! Log.message('Publisher stopping') ! s.close() class Contexts: *************** *** 86,92 **** def publish(self, host, port, obj): - import thread ior = self.__orb.object_to_string(obj._this()) ! thread.start_new_thread(publisher, (host, port, ior)) def run(self): --- 104,109 ---- def publish(self, host, port, obj): ior = self.__orb.object_to_string(obj._this()) ! return Publisher(host, port, ior) def run(self): |