Socket server and threads

Rob Brown-Bayliss rob at
Mon Sep 16 20:39:30 EDT 2002

Hi, I am trying to write an app. it Has a gui, and I am using xmlrpc via
socket server to communicate with other apps on other machines.

I currently have the socket server running as a thread like so:

args = (('', 48002), BHH_Communication.BHH_DMHandler, self)
	self.server = None
	self.tserver = thread.start_new_thread(BHH_Communication.BHH_TCPServer,
	while (self.server == None):

where BHH_TPCServer is:

class BHH_TCPServer(SocketServer.TCPServer):
	def __init__(self, server_address, RequestHandlerClass, parent):
		SocketServer.TCPServer.__init__(self, server_address,
		self.BHH = parent
		self.BHH.server = self   # so handlers have access to 					 # GUI app
		self.in_comms = []
		self.out_comms = []
		while 1:
			rtoread, rtowrite, err = ,
self.out_comms, [], 5.0)
			if (len(rtoread) != 0):

So with this my handler class can call functions in the main app via

My question is what do I need to do to make sure it is safe, what
happens if the thread and the parent app are trying to call the same
function at  the same time?  What about if two or more request handlers
are running and want the same function at the same time (via a threaded
TCP handler class?


*  Rob Brown-Bayliss

More information about the Python-list mailing list