"Maurice LING" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> I do have another dumb question which is OT here. Say aFunc method > instantiates a SOAP server that serves forever, will it prevent bFunc > from running as a separate thread? If the SOAP server thread never sleeps or block, it will effectively stop everything else in your program by eating all the CPU time available. If it does some IO and other OS functions, probably not because it is likely to block on those - I do not know SOAPpy in detail, but it being a socket-based server it should end up in a select loop somewhere. i.e. block when no work is available. which is what you want. > For example, > > class myClass4: > def repeat(self, s): return s+s > def aFunc(self, a): > import SOAPpy > serv = SOAPpy.SOAPServer((a[0], a[1])) > serv.registerFunction(repeat) > serv.serve_forever() > def bFunc(self, b): pass > def runAll(self, a, b): > threading.Thread(target=self.aFunc, args = (a)).start() > threading.Thread(target=self.bFunc, args = (b)).start() > > if __name__=='__main__': myClass4().runAll(['localhost', 8000], 'hi') > > Will the 2nd thread (bFunc) ever run since the 1st thread is running > forever? Intuitively, I think that both threads will run but I just want > to be doubly sure, because some of my program logic depends on the 2nd > thread running while the 1st thread acts as a SOAP server or something. Both should run independently, sharing the CPU-time available for your application. Remember "main" is a thread too, so you will want "main" to hang around while your threads are running and you will want "main" to block on something also, thread.join(), time.sleep(), command line parser e.t.c. whatever is natural. -- http://mail.python.org/mailman/listinfo/python-list