Search code examples
python-3.xmultithreadingpython-multithreadingpyropyro4

MultiThread Python Pyro4 daemon.requestLoop()


Ive been using Pyro4 to build a private chat application. Below is my code of declaring Pyro4 daemon.

import Pyro4


@Pyro4.expose
class GreetingMaker(object):
    def get_fortune(self, name):
        return "Hello, {0}. Here is your fortune message:\n" \
           "Behold the warranty -- the bold print giveth and the fine print taketh away.".format(name)



print('Instantiates Pyro4 Daemon')
daemon = Pyro4.Daemon()       
uri_str = daemon.register(GreeetingMaker)
print('Before Request Loop')
Thread(target=daemon.requestLoop()).start()
print('After Pyro4 Daemon')

My code cannot get through daemon.requestLoop() . It is stuck there. I want the code after that to be executed for some reasons so I decided to multithread it, but my code doesn't work. Please tell me how to do it.


Solution

  • Ive been banging my head for almost two days about this, and at last I figured it out. I changed my code to:

    Thread(target=daemon.requestLoop).start()