the background of the program.
A HTTP server is front end for a Fileserver and use Pyro RMI to load / write files on the Fileserver. before a client is allowed access to the files a security handshake must be done. It all works when I run it. Now I would like to have the HTTP server run threaded so it can handle multiple clients at once.

I change the connection accepting part in the HTTP server from

while(True):
  try:
    channel = serverSocket.accept()
    ServerHandshake(channel[0],channel[1])

To

while(True):
  try:
    channel = serverSocket.accept()
     thread.start_new_thread(ServerHandshake,(channel[0],channel[1]))

It all goes fine through the handshake and until it is time to make the Pyro proxy for the command, I have 3 lines like:

print 'in getfunc just before proxy'
    PP = Pyro.core.getProxyForURI("PYROLOC://127.0.1.1:7766/FSClass")
    print 'proxy made'

And the thread stalls after doing the first print, when I give the program a CTRL+C keyboard interrupt it stops listening for new connections and any stalled threads do the second print and finish their operation correctly.

Does anyone have an idea what can be going wrong ? I am personally all out of ideas by now.

I don't know if this is your problem, but pyro proxies can't be shared between different threads. I had this problem once and I was able to solve it by creating a thread devoted to driving a pyro proxy and calling it's methods. Other threads could use the proxy by putting 'method call requests' in a deque which was read by the proxy's own thread. All this was done using threading.Condition objects to manage the deque and also return values when necessary.

As far as I understand it shouldn't be it, I am trying to make the proxy inside each spawned thread and del it after I have used it, not have a proxy that the threads share (ServerHandshake is started in thread, ServerHandshake finishes handshake part and calls function1, function1 reads the header from client and calls GETFunc if it's a GET header, GETFunc makes the proxy to load the file from Fileserver - If that makes any sense).

Thanks for the response though :).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.